From c734d91dfd102c5df0699b0a657bcc0a692e986d Mon Sep 17 00:00:00 2001 From: thomashii Date: Wed, 11 Aug 2021 09:37:37 +0800 Subject: [PATCH] Updated orm generator --- packages/orm/angel_orm_generator/CHANGELOG.md | 4 +++ packages/orm/angel_orm_generator/README.md | 4 +-- .../lib/src/orm_build_context.dart | 25 +++++++++++-------- packages/orm/angel_orm_generator/pubspec.yaml | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/packages/orm/angel_orm_generator/CHANGELOG.md b/packages/orm/angel_orm_generator/CHANGELOG.md index 1c7ac683..5e435b50 100644 --- a/packages/orm/angel_orm_generator/CHANGELOG.md +++ b/packages/orm/angel_orm_generator/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 4.0.2 + +* Fixed NNBD issues + ## 4.0.1 * Added `useNullSafetySyntax: true` to `DartEmitter` diff --git a/packages/orm/angel_orm_generator/README.md b/packages/orm/angel_orm_generator/README.md index a0ca4400..01967896 100644 --- a/packages/orm/angel_orm_generator/README.md +++ b/packages/orm/angel_orm_generator/README.md @@ -1,6 +1,6 @@ # Angel3 ORM Generator -[![version](https://img.shields.io/badge/pub-v4.0.1-brightgreen)](https://pub.dartlang.org/packages/angel3_orm_generator) +[![version](https://img.shields.io/badge/pub-v4.0.2-brightgreen)](https://pub.dartlang.org/packages/angel3_orm_generator) [![Null Safety](https://img.shields.io/badge/null-safety-brightgreen)](https://dart.dev/null-safety) [![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion) @@ -18,5 +18,5 @@ For documentation about the ORM, see [Developer Guide](https://angel3-docs.dukef Run the following command to generate the required `.g.dart` files for Angel3 ORM. ```bash - dart pub run build_runner build + dart run build_runner build ``` diff --git a/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart b/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart index f251c387..a0de492f 100644 --- a/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart +++ b/packages/orm/angel_orm_generator/lib/src/orm_build_context.dart @@ -276,19 +276,22 @@ Future buildOrmContext( // 'foreignKey=$foreignKey, localKey=$localKey'); if (relation.type == RelationshipType.belongsTo) { - var name = ReCase(relation.localKey!).camelCase; - ctx.buildContext.aliases[name] = relation.localKey; + var localKey = relation.localKey; + if (localKey != null) { + var name = ReCase(localKey).camelCase; + ctx.buildContext.aliases[name] = localKey; - if (!ctx.effectiveFields.any((f) => f.name == field.name)) { - var foreignField = relation.findForeignField(ctx); - var foreign = relation.throughContext ?? relation.foreign; - var type = foreignField.type; - if (isSpecialId(foreign, foreignField)) { - //type = field.type.element.context.typeProvider.intType; - type = field.type; + if (!ctx.effectiveFields.any((f) => f.name == field.name)) { + var foreignField = relation.findForeignField(ctx); + var foreign = relation.throughContext ?? relation.foreign; + var type = foreignField.type; + if (isSpecialId(foreign, foreignField)) { + //type = field.type.element.context.typeProvider.intType; + type = field.type; + } + var rf = RelationFieldImpl(name, relation, type, field); + ctx.effectiveFields.add(rf); } - var rf = RelationFieldImpl(name, relation, type, field); - ctx.effectiveFields.add(rf); } } diff --git a/packages/orm/angel_orm_generator/pubspec.yaml b/packages/orm/angel_orm_generator/pubspec.yaml index fe685101..fee09e5f 100644 --- a/packages/orm/angel_orm_generator/pubspec.yaml +++ b/packages/orm/angel_orm_generator/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_orm_generator -version: 4.0.1 +version: 4.0.2 description: Code generators for Angel3 ORM. Generates query builder classes. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/orm/angel_orm_generator