gen@2.0.1

This commit is contained in:
Tobe O 2019-04-20 18:01:42 -04:00
parent 51457cb846
commit fcdc1afa78
6 changed files with 14 additions and 9 deletions

View file

@ -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.

View file

@ -80,6 +80,8 @@ Future<OrmBuildContext> 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<OrmBuildContext> 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,

View file

@ -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 {

View file

@ -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 <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/orm

View file

@ -68,7 +68,7 @@ class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
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);
}

View file

@ -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<Leg, LegQueryWhere> {
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<Foot, FootQueryWhere> {
@override
get tableName {
return 'foots';
return 'feet';
}
@override