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

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.2
* Added performance benchmark to README
## 7.0.1
* 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.
## 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)

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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