gen@2.0.0-dev

This commit is contained in:
Tobe O 2018-12-08 18:15:36 -05:00
parent 21a430717c
commit ab66c2144b
4 changed files with 8 additions and 11 deletions

View file

@ -1,3 +1,6 @@
# 2.0.0-dev
* Dart 2 updates, and more.
# 1.0.0-alpha+6 # 1.0.0-alpha+6
* `DateTime` is now `CAST` on insertion and update operations. * `DateTime` is now `CAST` on insertion and update operations.

View file

@ -19,10 +19,6 @@ import 'readers.dart';
bool isHasRelation(Relationship r) => bool isHasRelation(Relationship r) =>
r.type == RelationshipType.hasOne || r.type == RelationshipType.hasMany; r.type == RelationshipType.hasOne || r.type == RelationshipType.hasMany;
bool isBelongsRelation(Relationship r) =>
r.type == RelationshipType.belongsTo ||
r.type == RelationshipType.belongsToMany;
final Map<String, OrmBuildContext> _cache = {}; final Map<String, OrmBuildContext> _cache = {};
Future<OrmBuildContext> buildOrmContext( Future<OrmBuildContext> buildOrmContext(
@ -162,8 +158,7 @@ Future<OrmBuildContext> buildOrmContext(
if (type == RelationshipType.hasOne || type == RelationshipType.hasMany) { if (type == RelationshipType.hasOne || type == RelationshipType.hasMany) {
localKey ??= 'id'; localKey ??= 'id';
foreignKey ??= '${rc.snakeCase}_id'; foreignKey ??= '${rc.snakeCase}_id';
} else if (type == RelationshipType.belongsTo || } else if (type == RelationshipType.belongsTo) {
type == RelationshipType.belongsToMany) {
localKey ??= '${rcc.snakeCase}_id'; localKey ??= '${rcc.snakeCase}_id';
foreignKey ??= 'id'; foreignKey ??= 'id';
} }
@ -176,7 +171,7 @@ Future<OrmBuildContext> buildOrmContext(
cascadeOnDelete: cascadeOnDelete, cascadeOnDelete: cascadeOnDelete,
); );
if (isBelongsRelation(relation)) { if (relation.type == RelationshipType.belongsTo) {
var name = new ReCase(relation.localKey).camelCase; var name = new ReCase(relation.localKey).camelCase;
ctx.buildContext.aliases[name] = relation.localKey; ctx.buildContext.aliases[name] = relation.localKey;

View file

@ -434,7 +434,7 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
builderType = refer('DateTimeSqlExpressionBuilder'); builderType = refer('DateTimeSqlExpressionBuilder');
} else if (ctx.relations.containsKey(field.name)) { } else if (ctx.relations.containsKey(field.name)) {
var relation = ctx.relations[field.name]; var relation = ctx.relations[field.name];
if (!isBelongsRelation(relation)) if (relation.type != RelationshipType.belongsTo)
continue; continue;
else { else {
builderType = new TypeReference((b) => b builderType = new TypeReference((b) => b

View file

@ -1,13 +1,12 @@
name: angel_orm_generator name: angel_orm_generator
version: 2.0.0-alpha version: 2.0.0-dev
description: Code generators for Angel's ORM. Generates query builder classes. description: Code generators for Angel's ORM. Generates query builder classes.
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/orm homepage: https://github.com/angel-dart/orm
environment: environment:
sdk: ">=2.0.0-dev <3.0.0" sdk: ">=2.0.0-dev <3.0.0"
dependencies: dependencies:
angel_orm: angel_orm: ^2.0.0-dev
path: ../angel_orm
angel_serialize_generator: ^2.0.0 angel_serialize_generator: ^2.0.0
build: ">=0.12.0 <2.0.0" build: ">=0.12.0 <2.0.0"
build_config: ^0.3.0 build_config: ^0.3.0