Merge pull request #85 from dukefirehawk/bug-fix/deprecated

Fixing warnings
This commit is contained in:
Thomas Hii 2022-10-03 23:34:17 +08:00 committed by GitHub
commit b9b0e49fd0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 45 additions and 18 deletions

View file

@ -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) 1. Download and install [Dart](https://dart.dev/get-dart)
2. Clone one of the following starter projects: 2. Clone one of the following starter projects:
* [Basic Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-basic) * [Angel3 Basic Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-basic)
* [ORM for PostgreSQL Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-orm) * [Angel3 ORM Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm)
* [ORM for MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-orm-mysql) * [Angel3 ORM MySQL Template](https://github.com/dukefirehawk/boilerplates/tree/v7/angel3-orm-mysql)
* [Angel3 Graphql Template](https://github.com/dukefirehawk/boilerplates/tree/angel3-graphql) * [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). 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. 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 1. Cached queries
2. Cached queries 2. Angel3 with MongoDB
3. Angel3 with MongoDB
## Examples and Documentation ## Examples and Documentation

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 7.0.2
* Added performance benchmark to README
## 7.0.1 ## 7.0.1
* Fixed `BytesBuilder` warnings * Fixed `BytesBuilder` warnings

View file

@ -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. 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 ### 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) Check out [Migrating to Angel3](https://angel3-docs.dukefirehawk.com/migration/angel-2.x.x-to-angel3/migration-guide-3)

View file

@ -1,5 +1,5 @@
name: angel3_framework 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. description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 7.0.2
* Fixed deprecated `assignVar` and `assignConst`
## 7.0.1 ## 7.0.1
* Fixed issue #82: Fixed issue #82: Removed casting for numeric fields * Fixed issue #82: Fixed issue #82: Removed casting for numeric fields

View file

@ -11,6 +11,7 @@ import 'package:dart_style/dart_style.dart';
import 'package:source_gen/source_gen.dart' hide LibraryBuilder; import 'package:source_gen/source_gen.dart' hide LibraryBuilder;
import 'orm_build_context.dart'; import 'orm_build_context.dart';
/// Migration Builder
Builder migrationBuilder(BuilderOptions options) { Builder migrationBuilder(BuilderOptions options) {
return SharedPartBuilder([ return SharedPartBuilder([
MigrationGenerator( MigrationGenerator(
@ -18,6 +19,7 @@ Builder migrationBuilder(BuilderOptions options) {
], 'angel3_migration'); ], 'angel3_migration');
} }
/// Generates `<Model>Migration.dart` from an abstract `Model` class.
class MigrationGenerator extends GeneratorForAnnotation<Orm> { class MigrationGenerator extends GeneratorForAnnotation<Orm> {
static final Parameter _schemaParam = Parameter((b) => b static final Parameter _schemaParam = Parameter((b) => b
..name = 'schema' ..name = 'schema'
@ -72,6 +74,7 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
}); });
} }
/// Generate up() method to create tables
Method buildUpMigration(OrmBuildContext ctx, LibraryBuilder lib) { Method buildUpMigration(OrmBuildContext ctx, LibraryBuilder lib) {
return Method((meth) { return Method((meth) {
// Check to see if clazz extends Model class // 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) { Method buildDownMigration(OrmBuildContext? ctx) {
return Method((b) { return Method((b) {
b b

View file

@ -56,6 +56,7 @@ FieldElement? findPrimaryFieldInList(
return specialId; return specialId;
} }
/// Create ORM Context
Future<OrmBuildContext?> buildOrmContext( Future<OrmBuildContext?> buildOrmContext(
Map<String, OrmBuildContext> cache, Map<String, OrmBuildContext> cache,
InterfaceElement clazz, InterfaceElement clazz,
@ -337,7 +338,7 @@ Future<OrmBuildContext?> buildOrmContext(
return ctx; return ctx;
} }
// Detect and return the correct column type /// Detect and return the correct column type
ColumnType inferColumnType(DartType type) { ColumnType inferColumnType(DartType type) {
if (const TypeChecker.fromRuntime(String).isAssignableFromType(type)) { if (const TypeChecker.fromRuntime(String).isAssignableFromType(type)) {
return ColumnType.varChar; return ColumnType.varChar;

View file

@ -31,7 +31,7 @@ TypeReference futureOf(String type) {
..types.add(refer(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> { class OrmGenerator extends GeneratorForAnnotation<Orm> {
final bool? autoSnakeCaseNames; final bool? autoSnakeCaseNames;
@ -159,7 +159,9 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
.map((f) => .map((f) =>
literalString(ctx.buildContext.resolveFieldName(f.name)!)) literalString(ctx.buildContext.resolveFieldName(f.name)!))
.toList(); .toList();
b.addExpression(literalConstList(names).assignConst('_fields')); //b.addExpression(literalConstList(names).assignConst('_fields'));
b.addExpression(
declareConst('_fields').assign(literalConstList(names)));
b.addExpression(refer('_selectedFields') b.addExpression(refer('_selectedFields')
.property('isEmpty') .property('isEmpty')
.conditional( .conditional(
@ -315,8 +317,10 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
'if (row.every((x) => x == null)) { return Optional.empty(); }')); 'if (row.every((x) => x == null)) { return Optional.empty(); }'));
//b.addExpression(refer('0').assignVar('_index')); //b.addExpression(refer('0').assignVar('_index'));
b.addExpression(ctx.buildContext.modelClassType //b.addExpression(ctx.buildContext.modelClassType
.newInstance([], args).assignVar('model')); // .newInstance([], args).assignVar('model'));
b.addExpression(declareVar('model')
.assign(ctx.buildContext.modelClassType.newInstance([], args)));
ctx.relations.forEach((name, relation) { ctx.relations.forEach((name, relation) {
if (!const [ if (!const [
@ -369,7 +373,8 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
//var block = //var block =
// Block((b) => b.addExpression(refer('model').assign(expr))); // 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 e = refer('Optional').property('ifPresent').call([]);
var val = var val =

View file

@ -1,5 +1,5 @@
name: angel3_orm_generator name: angel3_orm_generator
version: 7.0.1 version: 7.0.2
description: Code generators for Angel3 ORM. Generates query builder classes. description: Code generators for Angel3 ORM. Generates query builder classes.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 7.0.2
* Fixed null safety warnings
## 7.0.1 ## 7.0.1
* Fixed issue #82: Removed casting for numeric fields * Fixed issue #82: Removed casting for numeric fields

View file

@ -98,7 +98,7 @@ class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
type: fields.contains('type') type: fields.contains('type')
? row[3] == null ? row[3] == null
? null ? null
: CarType?.values[(row[3] as int)] : CarType.values[(row[3] as int)]
: null, : null,
); );
return Optional.of(model); return Optional.of(model);
@ -171,7 +171,7 @@ class HasCarQueryValues extends MapQueryValues {
set updatedAt(DateTime? value) => values['updated_at'] = value; set updatedAt(DateTime? value) => values['updated_at'] = value;
CarType? get type { 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; set type(CarType? value) => values['type'] = value?.index;

View file

@ -1,5 +1,5 @@
name: angel3_orm_test 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. description: Common tests for Angel3 ORM. Reference implmentation of the generated ORM files.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_test repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_test