Updated orm generator

This commit is contained in:
thomashii 2021-08-11 09:37:37 +08:00
parent 1bd40f28b4
commit c734d91dfd
4 changed files with 21 additions and 14 deletions

View file

@ -1,5 +1,9 @@
# Change Log
## 4.0.2
* Fixed NNBD issues
## 4.0.1
* Added `useNullSafetySyntax: true` to `DartEmitter`

View file

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

View file

@ -276,19 +276,22 @@ Future<OrmBuildContext?> 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);
}
}

View file

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