From 6a3354503782f0436d32ebb354f1ac1d8ebda471 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Mon, 3 Oct 2022 23:22:39 +0800 Subject: [PATCH 1/2] Fixing warnings --- packages/orm/angel_orm_generator/CHANGELOG.md | 4 ++++ .../lib/src/migration_generator.dart | 4 ++++ .../lib/src/orm_build_context.dart | 3 ++- .../lib/src/orm_generator.dart | 15 ++++++++++----- packages/orm/angel_orm_generator/pubspec.yaml | 2 +- packages/orm/angel_orm_test/CHANGELOG.md | 4 ++++ .../angel_orm_test/lib/src/models/has_car.g.dart | 4 ++-- packages/orm/angel_orm_test/pubspec.yaml | 2 +- 8 files changed, 28 insertions(+), 10 deletions(-) diff --git a/packages/orm/angel_orm_generator/CHANGELOG.md b/packages/orm/angel_orm_generator/CHANGELOG.md index 49d9d8fe..f661f30b 100644 --- a/packages/orm/angel_orm_generator/CHANGELOG.md +++ b/packages/orm/angel_orm_generator/CHANGELOG.md @@ -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 diff --git a/packages/orm/angel_orm_generator/lib/src/migration_generator.dart b/packages/orm/angel_orm_generator/lib/src/migration_generator.dart index c7cb35df..2f40e657 100644 --- a/packages/orm/angel_orm_generator/lib/src/migration_generator.dart +++ b/packages/orm/angel_orm_generator/lib/src/migration_generator.dart @@ -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 `Migration.dart` from an abstract `Model` class. class MigrationGenerator extends GeneratorForAnnotation { static final Parameter _schemaParam = Parameter((b) => b ..name = 'schema' @@ -72,6 +74,7 @@ class MigrationGenerator extends GeneratorForAnnotation { }); } + /// 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 { }); } + /// Generate down() method to drop tables Method buildDownMigration(OrmBuildContext? ctx) { return Method((b) { b 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 3220b420..e28eb03a 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 @@ -56,6 +56,7 @@ FieldElement? findPrimaryFieldInList( return specialId; } +/// Create ORM Context Future buildOrmContext( Map cache, InterfaceElement clazz, @@ -337,7 +338,7 @@ Future 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; diff --git a/packages/orm/angel_orm_generator/lib/src/orm_generator.dart b/packages/orm/angel_orm_generator/lib/src/orm_generator.dart index 82e19664..c61e25c2 100644 --- a/packages/orm/angel_orm_generator/lib/src/orm_generator.dart +++ b/packages/orm/angel_orm_generator/lib/src/orm_generator.dart @@ -31,7 +31,7 @@ TypeReference futureOf(String type) { ..types.add(refer(type))); } -/// Builder that generates `.g.dart` from an abstract `Model` class. +/// Generate `.g.dart` from an abstract `Model` class. class OrmGenerator extends GeneratorForAnnotation { final bool? autoSnakeCaseNames; @@ -159,7 +159,9 @@ class OrmGenerator extends GeneratorForAnnotation { .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 { '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 { //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 = diff --git a/packages/orm/angel_orm_generator/pubspec.yaml b/packages/orm/angel_orm_generator/pubspec.yaml index 34c2ea0b..f695df0c 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: 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 diff --git a/packages/orm/angel_orm_test/CHANGELOG.md b/packages/orm/angel_orm_test/CHANGELOG.md index 374be1f5..bbc9f3fc 100644 --- a/packages/orm/angel_orm_test/CHANGELOG.md +++ b/packages/orm/angel_orm_test/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.2 + +* Fixed null safety warnings + ## 7.0.1 * Fixed issue #82: Removed casting for numeric fields diff --git a/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart b/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart index a015b11d..2cc6fb15 100644 --- a/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/has_car.g.dart @@ -98,7 +98,7 @@ class HasCarQuery extends Query { 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; diff --git a/packages/orm/angel_orm_test/pubspec.yaml b/packages/orm/angel_orm_test/pubspec.yaml index 610368b7..df6730f8 100644 --- a/packages/orm/angel_orm_test/pubspec.yaml +++ b/packages/orm/angel_orm_test/pubspec.yaml @@ -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 From 5e658703fa1340ef2965d8a5c824d04f5a7faf8e Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Mon, 3 Oct 2022 23:31:46 +0800 Subject: [PATCH 2/2] Updated README --- README.md | 13 ++++++------- packages/framework/CHANGELOG.md | 4 ++++ packages/framework/README.md | 6 ++++++ packages/framework/pubspec.yaml | 2 +- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 606b02d2..36456a29 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,10 @@ For more details, checkout [Project Status](https://github.com/dukefirehawk/ange 1. Download and install [Dart](https://dart.dev/get-dart) 2. Clone one of the following starter projects: - * [Basic Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-basic) - * [ORM for PostgreSQL Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-orm) - * [ORM for MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-orm-mysql) - * [Angel3 Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-graphql) + * [Angel3 Basic Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-basic) + * [Angel3 ORM Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm) + * [Angel3 ORM MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm-mysql) + * [Angel3 Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-graphql) 3. Run the project in development mode (*hot-reloaded* is enabled on file changes). @@ -135,9 +135,8 @@ The performance benchmark can be found at The test cases are build using standard `Angel3 ORM` template. The result are used for fine-tuning Angel3 framework. The following test cases will be added in the upcoming update to the benchmark. -1. Angel3 with ORM for MySQL -2. Cached queries -3. Angel3 with MongoDB +1. Cached queries +2. Angel3 with MongoDB ## Examples and Documentation diff --git a/packages/framework/CHANGELOG.md b/packages/framework/CHANGELOG.md index ba6d202d..5f6f56ce 100644 --- a/packages/framework/CHANGELOG.md +++ b/packages/framework/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 7.0.2 + +* Added performance benchmark to README + ## 7.0.1 * Fixed `BytesBuilder` warnings diff --git a/packages/framework/README.md b/packages/framework/README.md index 14d9593c..f9ad2475 100644 --- a/packages/framework/README.md +++ b/packages/framework/README.md @@ -68,6 +68,12 @@ This package is the core package of [Angel3](https://github.com/dukefirehawk/ang 6. Run as docker. Edit and build the image with the provided `Dockerfile` file. +## Performance Benchmark + +The performance benchmark can be found at + +[TechEmpower Framework Benchmarks Round 21](https://www.techempower.com/benchmarks/#section=data-r21&test=composite) + ### Migrating from Angel to Angel3 Check out [Migrating to Angel3](https://angel3-docs.dukefirehawk.com/migration/angel-2.x.x-to-angel3/migration-guide-3) diff --git a/packages/framework/pubspec.yaml b/packages/framework/pubspec.yaml index 9b31bb6c..d00acf9d 100644 --- a/packages/framework/pubspec.yaml +++ b/packages/framework/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_framework -version: 7.0.1 +version: 7.0.2 description: A high-powered HTTP server extensible framework with dependency injection, routing and much more. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework