gen 2.1.0-beta.1

This commit is contained in:
Tobe O 2019-10-09 15:39:25 -04:00
parent e99e040a50
commit c14a283861
8 changed files with 20 additions and 14 deletions

View file

@ -1,3 +1,8 @@
# 2.1.0-beta.1
* `OrmBuildContext` caching is now local to a `Builder`, so `watch`
*should* finally always run when required. Should resolve
[#85](https://github.com/angel-dart/orm/issues/85).
# 2.1.0-beta
* Relationships have always generated subqueries; now these subqueries are
available as `Query` objects on generated classes.

View file

@ -43,7 +43,7 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
}
var resolver = await buildStep.resolver;
var ctx = await buildOrmContext(element as ClassElement, annotation,
var ctx = await buildOrmContext({}, element as ClassElement, annotation,
buildStep, resolver, autoSnakeCaseNames != false);
var lib = generateMigrationLibrary(
ctx, element as ClassElement, resolver, buildStep);

View file

@ -58,9 +58,8 @@ FieldElement findPrimaryFieldInList(
return specialId;
}
final Map<String, OrmBuildContext> _cache = {};
Future<OrmBuildContext> buildOrmContext(
Map<String, OrmBuildContext> cache,
ClassElement clazz,
ConstantReader annotation,
BuildStep buildStep,
@ -79,8 +78,8 @@ Future<OrmBuildContext> buildOrmContext(
}
var id = clazz.location.components.join('-');
if (_cache.containsKey(id)) {
return _cache[id];
if (cache.containsKey(id)) {
return cache[id];
}
var buildCtx = await buildContext(
clazz, annotation, buildStep, resolver, autoSnakeCaseNames,
@ -94,7 +93,7 @@ Future<OrmBuildContext> buildOrmContext(
(ormAnnotation.tableName?.isNotEmpty == true)
? ormAnnotation.tableName
: pluralize(ReCase(clazz.name).snakeCase));
_cache[id] = ctx;
cache[id] = ctx;
// Read all fields
for (var field in buildCtx.fields) {
@ -173,6 +172,7 @@ Future<OrmBuildContext> buildOrmContext(
var modelType = firstModelAncestor(refType) ?? refType;
foreign = await buildOrmContext(
cache,
modelType.element as ClassElement,
ConstantReader(const TypeChecker.fromRuntime(Orm)
.firstAnnotationOf(modelType.element)),
@ -183,6 +183,7 @@ Future<OrmBuildContext> buildOrmContext(
// Resolve throughType as well
if (through != null && through is InterfaceType) {
throughContext = await buildOrmContext(
cache,
through.element,
ConstantReader(const TypeChecker.fromRuntime(Serializable)
.firstAnnotationOf(modelType.element)),

View file

@ -39,7 +39,7 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
Future<String> generateForAnnotatedElement(
Element element, ConstantReader annotation, BuildStep buildStep) async {
if (element is ClassElement) {
var ctx = await buildOrmContext(element, annotation, buildStep,
var ctx = await buildOrmContext({}, element, annotation, buildStep,
buildStep.resolver, autoSnakeCaseNames);
var lib = buildOrmLibrary(buildStep.inputId, ctx);
return lib.accept(DartEmitter()).toString();

View file

@ -1,5 +1,5 @@
name: angel_orm_generator
version: 2.1.0-beta
version: 2.1.0-beta.1
description: Code generators for Angel's ORM. Generates query builder classes.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/orm