Fixing warnings
This commit is contained in:
parent
6a7e251fee
commit
6a33545037
8 changed files with 28 additions and 10 deletions
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 7.0.2
|
||||
|
||||
* Fixed deprecated `assignVar` and `assignConst`
|
||||
|
||||
## 7.0.1
|
||||
|
||||
* Fixed issue #82: Fixed issue #82: Removed casting for numeric fields
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:dart_style/dart_style.dart';
|
|||
import 'package:source_gen/source_gen.dart' hide LibraryBuilder;
|
||||
import 'orm_build_context.dart';
|
||||
|
||||
/// Migration Builder
|
||||
Builder migrationBuilder(BuilderOptions options) {
|
||||
return SharedPartBuilder([
|
||||
MigrationGenerator(
|
||||
|
@ -18,6 +19,7 @@ Builder migrationBuilder(BuilderOptions options) {
|
|||
], 'angel3_migration');
|
||||
}
|
||||
|
||||
/// Generates `<Model>Migration.dart` from an abstract `Model` class.
|
||||
class MigrationGenerator extends GeneratorForAnnotation<Orm> {
|
||||
static final Parameter _schemaParam = Parameter((b) => b
|
||||
..name = 'schema'
|
||||
|
@ -72,6 +74,7 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
|
|||
});
|
||||
}
|
||||
|
||||
/// Generate up() method to create tables
|
||||
Method buildUpMigration(OrmBuildContext ctx, LibraryBuilder lib) {
|
||||
return Method((meth) {
|
||||
// Check to see if clazz extends Model class
|
||||
|
@ -351,6 +354,7 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
|
|||
});
|
||||
}
|
||||
|
||||
/// Generate down() method to drop tables
|
||||
Method buildDownMigration(OrmBuildContext? ctx) {
|
||||
return Method((b) {
|
||||
b
|
||||
|
|
|
@ -56,6 +56,7 @@ FieldElement? findPrimaryFieldInList(
|
|||
return specialId;
|
||||
}
|
||||
|
||||
/// Create ORM Context
|
||||
Future<OrmBuildContext?> buildOrmContext(
|
||||
Map<String, OrmBuildContext> cache,
|
||||
InterfaceElement clazz,
|
||||
|
@ -337,7 +338,7 @@ Future<OrmBuildContext?> buildOrmContext(
|
|||
return ctx;
|
||||
}
|
||||
|
||||
// Detect and return the correct column type
|
||||
/// Detect and return the correct column type
|
||||
ColumnType inferColumnType(DartType type) {
|
||||
if (const TypeChecker.fromRuntime(String).isAssignableFromType(type)) {
|
||||
return ColumnType.varChar;
|
||||
|
|
|
@ -31,7 +31,7 @@ TypeReference futureOf(String type) {
|
|||
..types.add(refer(type)));
|
||||
}
|
||||
|
||||
/// Builder that generates `<Model>.g.dart` from an abstract `Model` class.
|
||||
/// Generate `<Model>.g.dart` from an abstract `Model` class.
|
||||
class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
||||
final bool? autoSnakeCaseNames;
|
||||
|
||||
|
@ -159,7 +159,9 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
.map((f) =>
|
||||
literalString(ctx.buildContext.resolveFieldName(f.name)!))
|
||||
.toList();
|
||||
b.addExpression(literalConstList(names).assignConst('_fields'));
|
||||
//b.addExpression(literalConstList(names).assignConst('_fields'));
|
||||
b.addExpression(
|
||||
declareConst('_fields').assign(literalConstList(names)));
|
||||
b.addExpression(refer('_selectedFields')
|
||||
.property('isEmpty')
|
||||
.conditional(
|
||||
|
@ -315,8 +317,10 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
'if (row.every((x) => x == null)) { return Optional.empty(); }'));
|
||||
//b.addExpression(refer('0').assignVar('_index'));
|
||||
|
||||
b.addExpression(ctx.buildContext.modelClassType
|
||||
.newInstance([], args).assignVar('model'));
|
||||
//b.addExpression(ctx.buildContext.modelClassType
|
||||
// .newInstance([], args).assignVar('model'));
|
||||
b.addExpression(declareVar('model')
|
||||
.assign(ctx.buildContext.modelClassType.newInstance([], args)));
|
||||
|
||||
ctx.relations.forEach((name, relation) {
|
||||
if (!const [
|
||||
|
@ -369,7 +373,8 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
//var block =
|
||||
// Block((b) => b.addExpression(refer('model').assign(expr)));
|
||||
|
||||
var stmt = parsed.assignVar('modelOpt');
|
||||
var stmt = declareVar('modelOpt').assign(parsed);
|
||||
//parsed.assignVar('modelOpt');
|
||||
//var e = refer('Optional').property('ifPresent').call([]);
|
||||
|
||||
var val =
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_orm_generator
|
||||
version: 7.0.1
|
||||
version: 7.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/master/packages/orm/angel_orm_generator
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 7.0.2
|
||||
|
||||
* Fixed null safety warnings
|
||||
|
||||
## 7.0.1
|
||||
|
||||
* Fixed issue #82: Removed casting for numeric fields
|
||||
|
|
|
@ -98,7 +98,7 @@ class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
|
|||
type: fields.contains('type')
|
||||
? row[3] == null
|
||||
? null
|
||||
: CarType?.values[(row[3] as int)]
|
||||
: CarType.values[(row[3] as int)]
|
||||
: null,
|
||||
);
|
||||
return Optional.of(model);
|
||||
|
@ -171,7 +171,7 @@ class HasCarQueryValues extends MapQueryValues {
|
|||
|
||||
set updatedAt(DateTime? value) => values['updated_at'] = value;
|
||||
CarType? get type {
|
||||
return CarType?.values[(values['type'] as int)];
|
||||
return CarType.values[(values['type'] as int)];
|
||||
}
|
||||
|
||||
set type(CarType? value) => values['type'] = value?.index;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_orm_test
|
||||
version: 7.0.1
|
||||
version: 7.0.2
|
||||
description: Common tests for Angel3 ORM. Reference implmentation of the generated ORM files.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_test
|
||||
|
|
Loading…
Reference in a new issue