From fcdc1afa78fed724409ff87f7a31ae6b735147b2 Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 20 Apr 2019 18:01:42 -0400 Subject: [PATCH] gen@2.0.1 --- angel_orm_generator/CHANGELOG.md | 1 + angel_orm_generator/lib/src/orm_build_context.dart | 4 +++- angel_orm_generator/lib/src/readers.dart | 4 +++- angel_orm_generator/pubspec.yaml | 2 +- angel_orm_test/lib/src/models/has_car.g.dart | 4 ++-- angel_orm_test/lib/src/models/leg.g.dart | 8 ++++---- 6 files changed, 14 insertions(+), 9 deletions(-) diff --git a/angel_orm_generator/CHANGELOG.md b/angel_orm_generator/CHANGELOG.md index 2b623383..93bec717 100644 --- a/angel_orm_generator/CHANGELOG.md +++ b/angel_orm_generator/CHANGELOG.md @@ -1,5 +1,6 @@ # 2.0.1 * Gracefully handle `null` in enum fields. +* Add `take` to wherever `skip` is used. # 2.0.0+2 * Widen `analyzer` dependency range. diff --git a/angel_orm_generator/lib/src/orm_build_context.dart b/angel_orm_generator/lib/src/orm_build_context.dart index f22ed271..f350d600 100644 --- a/angel_orm_generator/lib/src/orm_build_context.dart +++ b/angel_orm_generator/lib/src/orm_build_context.dart @@ -80,6 +80,8 @@ Future buildOrmContext( clazz, annotation, buildStep, resolver, autoSnakeCaseNames, heedExclude: heedExclude); var ormAnnotation = reviveORMAnnotation(annotation); + // print( + // 'tableName (${annotation.objectValue.type.name}) => ${ormAnnotation.tableName} from ${clazz.name} (${annotation.revive().namedArguments})'); var ctx = new OrmBuildContext( buildCtx, ormAnnotation, @@ -164,7 +166,7 @@ Future buildOrmContext( foreign = await buildOrmContext( modelType.element as ClassElement, - new ConstantReader(const TypeChecker.fromRuntime(Serializable) + new ConstantReader(const TypeChecker.fromRuntime(Orm) .firstAnnotationOf(modelType.element)), buildStep, resolver, diff --git a/angel_orm_generator/lib/src/readers.dart b/angel_orm_generator/lib/src/readers.dart index 275b829d..4017168b 100644 --- a/angel_orm_generator/lib/src/readers.dart +++ b/angel_orm_generator/lib/src/readers.dart @@ -8,7 +8,9 @@ import 'orm_build_context.dart'; const TypeChecker columnTypeChecker = const TypeChecker.fromRuntime(Column); Orm reviveORMAnnotation(ConstantReader reader) { - return Orm(tableName: reader.peek('tableName')?.stringValue); + return Orm( + tableName: reader.peek('tableName')?.stringValue, + generateMigrations: reader.peek('generateMigrations')?.boolValue ?? true); } class ColumnReader { diff --git a/angel_orm_generator/pubspec.yaml b/angel_orm_generator/pubspec.yaml index fd28732a..15453cfb 100644 --- a/angel_orm_generator/pubspec.yaml +++ b/angel_orm_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_orm_generator -version: 2.0.0+2 +version: 2.0.1 description: Code generators for Angel's ORM. Generates query builder classes. author: Tobe O homepage: https://github.com/angel-dart/orm diff --git a/angel_orm_test/lib/src/models/has_car.g.dart b/angel_orm_test/lib/src/models/has_car.g.dart index 7886c6e5..24465baa 100644 --- a/angel_orm_test/lib/src/models/has_car.g.dart +++ b/angel_orm_test/lib/src/models/has_car.g.dart @@ -68,7 +68,7 @@ class HasCarQuery extends Query { if (row.every((x) => x == null)) return null; var model = HasCar( id: row[0].toString(), - type: CarType.values[(row[1] as int)], + type: row[1] == null ? null : CarType.values[(row[1] as int)], createdAt: (row[2] as DateTime), updatedAt: (row[3] as DateTime)); return model; @@ -116,7 +116,7 @@ class HasCarQueryValues extends MapQueryValues { return CarType.values[(values['type'] as int)]; } - set type(CarType value) => values['type'] = value.index; + set type(CarType value) => values['type'] = value?.index; DateTime get createdAt { return (values['created_at'] as DateTime); } diff --git a/angel_orm_test/lib/src/models/leg.g.dart b/angel_orm_test/lib/src/models/leg.g.dart index 69e926e5..e7b8c6cb 100644 --- a/angel_orm_test/lib/src/models/leg.g.dart +++ b/angel_orm_test/lib/src/models/leg.g.dart @@ -26,7 +26,7 @@ class LegMigration extends Migration { class FootMigration extends Migration { @override up(Schema schema) { - schema.create('foots', (table) { + schema.create('feet', (table) { table.serial('id')..primaryKey(); table.integer('leg_id'); table.declare('n_toes', ColumnType('decimal')); @@ -37,7 +37,7 @@ class FootMigration extends Migration { @override down(Schema schema) { - schema.drop('foots'); + schema.drop('feet'); } } @@ -50,7 +50,7 @@ class LegQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = LegQueryWhere(this); - leftJoin('foots', 'id', 'leg_id', + leftJoin('feet', 'id', 'leg_id', additionalFields: const [ 'id', 'leg_id', @@ -184,7 +184,7 @@ class FootQuery extends Query { @override get tableName { - return 'foots'; + return 'feet'; } @override