Upgrade library

This commit is contained in:
thomashii@dukefirehawk.com 2023-09-23 11:31:46 +08:00
parent 4dcf6883d0
commit 630c527381
9 changed files with 148 additions and 63 deletions

View file

@ -1,5 +1,9 @@
# Change Log
## 8.1.0
* Upgraded to `analyzer` 6.2.x
## 8.0.0
* Require Dart >= 3.0

View file

@ -1,11 +1,11 @@
name: jael3_web
version: 8.0.0
version: 8.1.0
description: Experimental virtual DOM/SPA engine built on Jael3. Supports SSR.
publish_to: none
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
analyzer: ^5.0.0
analyzer: ^6.2.0
build: ^2.0.2
build_config: ^1.0.0
code_builder: ^4.0.0

View file

@ -27,6 +27,7 @@ void main(List<String> args) async {
password: "Test123*",
secure: false);
// ignore: unused_local_variable
var mysqlMigrationRunner = MySqlMigrationRunner(
mySQLConn,
migrations: [

View file

@ -1,5 +1,9 @@
# Change Log
## 8.1.0
* Upgraded to `analyzer` 6.2.x
## 8.0.0
* Require Dart >= 3.0

View file

@ -9,15 +9,29 @@ part of 'main.dart';
class EmployeeMigration extends Migration {
@override
void up(Schema schema) {
schema.create('employees', (table) {
table.serial('id').primaryKey();
table.timeStamp('created_at');
table.timeStamp('updated_at');
table.varChar('unique_id', length: 255).unique();
table.varChar('first_name', length: 255);
table.varChar('last_name', length: 255);
table.double('salary');
});
schema.create(
'employees',
(table) {
table.serial('id').primaryKey();
table.timeStamp('created_at');
table.timeStamp('updated_at');
table
.varChar(
'unique_id',
length: 255,
)
.unique();
table.varChar(
'first_name',
length: 255,
);
table.varChar(
'last_name',
length: 255,
);
table.double('salary');
},
);
}
@override
@ -31,8 +45,10 @@ class EmployeeMigration extends Migration {
// **************************************************************************
class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
EmployeeQuery({Query? parent, Set<String>? trampoline})
: super(parent: parent) {
EmployeeQuery({
Query? parent,
Set<String>? trampoline,
}) : super(parent: parent) {
trampoline ??= <String>{};
trampoline.add(tableName);
_where = EmployeeQueryWhere(this);
@ -47,7 +63,7 @@ class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
@override
Map<String, String> get casts {
return {'salary': 'char'};
return {};
}
@override
@ -64,7 +80,7 @@ class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
'unique_id',
'first_name',
'last_name',
'salary'
'salary',
];
return _selectedFields.isEmpty
? _fields
@ -91,17 +107,16 @@ class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
return Optional.empty();
}
var model = Employee(
id: fields.contains('id') ? row[0].toString() : null,
createdAt: fields.contains('created_at')
? mapToNullableDateTime(row[1])
: null,
updatedAt: fields.contains('updated_at')
? mapToNullableDateTime(row[2])
: null,
uniqueId: fields.contains('unique_id') ? (row[3] as String?) : null,
firstName: fields.contains('first_name') ? (row[4] as String?) : null,
lastName: fields.contains('last_name') ? (row[5] as String?) : null,
salary: fields.contains('salary') ? mapToDouble(row[6]) : null);
id: fields.contains('id') ? row[0].toString() : null,
createdAt:
fields.contains('created_at') ? mapToNullableDateTime(row[1]) : null,
updatedAt:
fields.contains('updated_at') ? mapToNullableDateTime(row[2]) : null,
uniqueId: fields.contains('unique_id') ? (row[3] as String?) : null,
firstName: fields.contains('first_name') ? (row[4] as String?) : null,
lastName: fields.contains('last_name') ? (row[5] as String?) : null,
salary: fields.contains('salary') ? mapToDouble(row[6]) : null,
);
return Optional.of(model);
}
@ -113,13 +128,34 @@ class EmployeeQuery extends Query<Employee, EmployeeQueryWhere> {
class EmployeeQueryWhere extends QueryWhere {
EmployeeQueryWhere(EmployeeQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at'),
uniqueId = StringSqlExpressionBuilder(query, 'unique_id'),
firstName = StringSqlExpressionBuilder(query, 'first_name'),
lastName = StringSqlExpressionBuilder(query, 'last_name'),
salary = NumericSqlExpressionBuilder<double>(query, 'salary');
: id = NumericSqlExpressionBuilder<int>(
query,
'id',
),
createdAt = DateTimeSqlExpressionBuilder(
query,
'created_at',
),
updatedAt = DateTimeSqlExpressionBuilder(
query,
'updated_at',
),
uniqueId = StringSqlExpressionBuilder(
query,
'unique_id',
),
firstName = StringSqlExpressionBuilder(
query,
'first_name',
),
lastName = StringSqlExpressionBuilder(
query,
'last_name',
),
salary = NumericSqlExpressionBuilder<double>(
query,
'salary',
);
final NumericSqlExpressionBuilder<int> id;
@ -137,14 +173,22 @@ class EmployeeQueryWhere extends QueryWhere {
@override
List<SqlExpressionBuilder> get expressionBuilders {
return [id, createdAt, updatedAt, uniqueId, firstName, lastName, salary];
return [
id,
createdAt,
updatedAt,
uniqueId,
firstName,
lastName,
salary,
];
}
}
class EmployeeQueryValues extends MapQueryValues {
@override
Map<String, String> get casts {
return {'salary': 'double precision'};
return {};
}
String? get id {
@ -198,14 +242,15 @@ class EmployeeQueryValues extends MapQueryValues {
@generatedSerializable
class Employee extends _Employee {
Employee(
{this.id,
this.createdAt,
this.updatedAt,
this.uniqueId,
this.firstName,
this.lastName,
this.salary});
Employee({
this.id,
this.createdAt,
this.updatedAt,
this.uniqueId,
this.firstName,
this.lastName,
this.salary,
});
/// A unique identifier corresponding to this item.
@override
@ -231,14 +276,15 @@ class Employee extends _Employee {
@override
double? salary;
Employee copyWith(
{String? id,
DateTime? createdAt,
DateTime? updatedAt,
String? uniqueId,
String? firstName,
String? lastName,
double? salary}) {
Employee copyWith({
String? id,
DateTime? createdAt,
DateTime? updatedAt,
String? uniqueId,
String? firstName,
String? lastName,
double? salary,
}) {
return Employee(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
@ -263,8 +309,15 @@ class Employee extends _Employee {
@override
int get hashCode {
return hashObjects(
[id, createdAt, updatedAt, uniqueId, firstName, lastName, salary]);
return hashObjects([
id,
createdAt,
updatedAt,
uniqueId,
firstName,
lastName,
salary,
]);
}
@override
@ -347,7 +400,7 @@ abstract class EmployeeFields {
uniqueId,
firstName,
lastName,
salary
salary,
];
static const String id = 'id';

View file

@ -1,5 +1,5 @@
name: angel3_orm_generator
version: 8.0.0
version: 8.1.0
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
@ -10,7 +10,7 @@ dependencies:
angel3_serialize: ^8.0.0
angel3_orm: ^8.0.0
angel3_serialize_generator: ^8.0.0
analyzer: ^5.13.0
analyzer: ^6.2.0
inflection3: ^0.5.3+2
build: ^2.4.0
build_config: ^1.1.0
@ -30,7 +30,7 @@ dev_dependencies:
postgres: ^2.4.0
test: ^1.24.0
lints: ^2.1.0
# dependency_overrides:
dependency_overrides:
# angel3_container:
# path: ../../container/angel_container
# angel3_framework:
@ -45,8 +45,8 @@ dev_dependencies:
# path: ../../mock_request
# angel3_serialize:
# path: ../../serialize/angel_serialize
# angel3_serialize_generator:
# path: ../../serialize/angel_serialize_generator
angel3_serialize_generator:
path: ../../serialize/angel_serialize_generator
# angel3_orm:
# path: ../angel_orm
# angel3_migration:

View file

@ -1,5 +1,9 @@
# Change Log
## 8.1.0
* Upgraded to `analyzer` 6.2.x
## 8.0.1
* Fixed `JsonModelGenerator` from generating duplicated fields

View file

@ -5,6 +5,25 @@
[![Gitter](https://img.shields.io/gitter/room/angel_dart/discussion)](https://gitter.im/angel_dart/discussion)
[![License](https://img.shields.io/github/license/dukefirehawk/angel)](https://github.com/dukefirehawk/angel/tree/master/packages/serialize/angel_serialize_generator/LICENSE)
The builder for Angel3 model serialization.
The builder for Angel3 serialization.
Find documentation in the main [serialize project repo](https://github.com/dukefirehawk/angel/tree/master/packages/serialize)
## Usage
1. Create a model class in `todo.dart` and annotate it with `@serializable`
```dart
import 'package:angel3_serialize/angel3_serialize.dart';
part 'todo.g.dart';
@serializable
class _Todo {
String? text;
bool? completed;
}
```
2. Run the following command to generate the associated `todo.g.dart` file for serialization.
```bash
dart run build_runner build
```

View file

@ -1,12 +1,12 @@
name: angel3_serialize_generator
version: 8.0.1
version: 8.1.0
description: Angel3 model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/serialize/angel_serialize_generator
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
analyzer: ^5.0.0
analyzer: ^6.2.0
angel3_model: ^8.0.0
angel3_serialize: ^8.0.0
belatuk_code_buffer: ^5.0.0