From c30609f955cde02f3cb7db17a11fef9b41a24d9c Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Sat, 30 Jul 2022 23:08:38 +0800 Subject: [PATCH] Fixed postgreSQL failed test cases --- .../{mysql_sql_main.dart => mysql_main.dart} | 0 experiment/db/bin/pg_main.dart | 53 +++++++++++++++++++ experiment/db/pubspec.yaml | 2 + packages/orm/angel_orm/lib/src/util.dart | 10 ++++ .../lib/src/orm_generator.dart | 7 ++- .../orm/angel_orm_mysql/example/main.dart | 6 +-- packages/orm/angel_orm_postgres/pubspec.yaml | 10 ++-- .../lib/src/models/asset.g.dart | 16 ++++-- .../angel_orm_test/lib/src/models/bike.g.dart | 8 ++- .../angel_orm_test/lib/src/models/boat.g.dart | 8 ++- .../angel_orm_test/lib/src/models/book.g.dart | 16 ++++-- .../angel_orm_test/lib/src/models/car.g.dart | 13 +++-- .../lib/src/models/custom_expr.g.dart | 16 ++++-- .../lib/src/models/has_car.g.dart | 8 ++- .../angel_orm_test/lib/src/models/leg.g.dart | 16 ++++-- .../lib/src/models/order.g.dart | 21 +++++--- .../lib/src/models/person.g.dart | 8 ++- .../lib/src/models/person_order.g.dart | 16 ++++-- .../angel_orm_test/lib/src/models/tree.g.dart | 16 ++++-- .../lib/src/models/unorthodox.g.dart | 8 ++- .../angel_orm_test/lib/src/models/user.g.dart | 16 ++++-- 21 files changed, 216 insertions(+), 58 deletions(-) rename experiment/db/bin/{mysql_sql_main.dart => mysql_main.dart} (100%) create mode 100644 experiment/db/bin/pg_main.dart diff --git a/experiment/db/bin/mysql_sql_main.dart b/experiment/db/bin/mysql_main.dart similarity index 100% rename from experiment/db/bin/mysql_sql_main.dart rename to experiment/db/bin/mysql_main.dart diff --git a/experiment/db/bin/pg_main.dart b/experiment/db/bin/pg_main.dart new file mode 100644 index 00000000..7c6397f4 --- /dev/null +++ b/experiment/db/bin/pg_main.dart @@ -0,0 +1,53 @@ +import 'dart:io'; + +import 'package:postgres/postgres.dart'; + +void main() async { + /* + * Granting permission in postgres + * grant all privileges on database orm_test to test; + * grant all privileges on sequence users_id_seq to test; + */ + print("=== Start 'postgres' driver test"); + await testPgDriver().catchError((error, stackTrace) { + print(error); + }); + print("=== End test"); + print(" "); + + exit(0); +} + +Future testPgDriver() async { + var conn = PostgreSQLConnection('localhost', 5432, 'orm_test', + username: 'test', password: 'test123'); + await conn.open(); + + print(">Test Select All"); + var result = await conn.query("SELECT * from users"); + print("Total records: ${result.length}"); + for (var row in result) { + print(row[0]); + for (var element in row) { + print(element); + } + } + + print(">Test Insert"); + var params = { + "username": "test", + "password": "test123", + "email": "test@demo.com", + "updatedAt": DateTime.parse("1970-01-01 00:00:00") + }; + + result = await conn.query( + "INSERT INTO users (username, password, email, updated_at) VALUES (@username, @password, @email, @updatedAt)", + substitutionValues: params); + //print("Last inserted ID: ${result.}"); + + //print(">Test Select By ID"); + //result = await conn.query("SELECT * from users where id=@id", + // substitutionValues: {"id": result}); + //print("Read record: ${result.length}"); +} diff --git a/experiment/db/pubspec.yaml b/experiment/db/pubspec.yaml index f19525c9..0815302f 100644 --- a/experiment/db/pubspec.yaml +++ b/experiment/db/pubspec.yaml @@ -8,5 +8,7 @@ published_to: none dependencies: mysql1: ^0.20.0 mysql_client: ^0.0.24 + postgres: ^2.4.1 + postgres_pool: ^2.1.3 dev_dependencies: lints: ^1.0.0 \ No newline at end of file diff --git a/packages/orm/angel_orm/lib/src/util.dart b/packages/orm/angel_orm/lib/src/util.dart index 28604fef..eeab7c10 100644 --- a/packages/orm/angel_orm/lib/src/util.dart +++ b/packages/orm/angel_orm/lib/src/util.dart @@ -22,6 +22,8 @@ String mapToText(dynamic value) { return value; } +/// Helper method to convert dynamic value to DateTime. +/// If null return January 1st, 1970 at 00:00:00 UTC as default DateTime mapToDateTime(dynamic value) { if (value == null) { return defaultDate; @@ -32,6 +34,14 @@ DateTime mapToDateTime(dynamic value) { return value; } +/// Helper method to convert dynamic value to nullable DateTime +DateTime? mapToNullableDateTime(dynamic value) { + if (value is String) { + return DateTime.tryParse(value); + } + return value; +} + double mapToDouble(dynamic value) { if (value == null) { return 0.0; 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 8488c7f8..7cbbbce9 100644 --- a/packages/orm/angel_orm_generator/lib/src/orm_generator.dart +++ b/packages/orm/angel_orm_generator/lib/src/orm_generator.dart @@ -274,9 +274,12 @@ class OrmGenerator extends GeneratorForAnnotation { // Generated Code: mapToBool(row[i]) expr = refer('mapToBool').call([expr]); } else if (fType.element?.displayName == 'DateTime') { - // print("fType: ${fType.element?.displayName}"); // Generated Code: mapToDateTime(row[i]) - expr = refer('mapToDateTime').call([expr]); + if (fType.nullabilitySuffix == NullabilitySuffix.question) { + expr = refer('mapToNullableDateTime').call([expr]); + } else { + expr = refer('mapToDateTime').call([expr]); + } } else { // Generated Code: (row[i] as type?) expr = expr.asA(type); diff --git a/packages/orm/angel_orm_mysql/example/main.dart b/packages/orm/angel_orm_mysql/example/main.dart index a32806d7..58f16e3e 100644 --- a/packages/orm/angel_orm_mysql/example/main.dart +++ b/packages/orm/angel_orm_mysql/example/main.dart @@ -13,8 +13,8 @@ part 'main.g.dart'; void main() async { //hierarchicalLoggingEnabled = true; - await mariaDBExample(); - //await mysqlExample(); + //await mariaDBExample(); + await mysqlExample(); exit(0); } @@ -62,7 +62,7 @@ Future mysqlExample() async { databaseName: "orm_test", userName: "test", password: "test123", - secure: false); + secure: true); print("Connected to MySQL"); var logger = Logger('orm_mysql'); diff --git a/packages/orm/angel_orm_postgres/pubspec.yaml b/packages/orm/angel_orm_postgres/pubspec.yaml index 5dd8d8aa..3abe1ae0 100644 --- a/packages/orm/angel_orm_postgres/pubspec.yaml +++ b/packages/orm/angel_orm_postgres/pubspec.yaml @@ -17,13 +17,13 @@ dev_dependencies: test: ^1.21.0 lints: ^1.0.0 dependency_overrides: -# angel3_serialize: -# path: ../../serialize/angel_serialize + angel3_serialize: + path: ../../serialize/angel_serialize # angel3_model: # path: ../../model - angel3_orm_test: + angel3_orm_test: path: ../angel_orm_test - angel3_orm: + angel3_orm: path: ../angel_orm - angel3_migration: + angel3_migration: path: ../angel_migration diff --git a/packages/orm/angel_orm_test/lib/src/models/asset.g.dart b/packages/orm/angel_orm_test/lib/src/models/asset.g.dart index ef882202..b6fb1813 100644 --- a/packages/orm/angel_orm_test/lib/src/models/asset.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/asset.g.dart @@ -99,8 +99,12 @@ class ItemQuery extends Query { } var model = Item( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, description: fields.contains('description') ? (row[3] as String) : ''); return Optional.of(model); } @@ -236,8 +240,12 @@ class AssetQuery extends Query { } var model = Asset( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, description: fields.contains('description') ? (row[3] as String) : '', name: fields.contains('name') ? (row[4] as String) : '', price: fields.contains('price') ? mapToDouble(row[5]) : 0.0); diff --git a/packages/orm/angel_orm_test/lib/src/models/bike.g.dart b/packages/orm/angel_orm_test/lib/src/models/bike.g.dart index 9397418d..db854073 100644 --- a/packages/orm/angel_orm_test/lib/src/models/bike.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/bike.g.dart @@ -95,8 +95,12 @@ class BikeQuery extends Query { } var model = Bike( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, make: fields.contains('make') ? (row[3] as String) : '', description: fields.contains('description') ? (row[4] as String) : '', familyFriendly: diff --git a/packages/orm/angel_orm_test/lib/src/models/boat.g.dart b/packages/orm/angel_orm_test/lib/src/models/boat.g.dart index 62da26e3..ba5405cf 100644 --- a/packages/orm/angel_orm_test/lib/src/models/boat.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/boat.g.dart @@ -95,8 +95,12 @@ class BoatQuery extends Query { } var model = Boat( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, make: fields.contains('make') ? (row[3] as String) : '', description: fields.contains('description') ? (row[4] as String) : '', familyFriendly: diff --git a/packages/orm/angel_orm_test/lib/src/models/book.g.dart b/packages/orm/angel_orm_test/lib/src/models/book.g.dart index 7d954e42..b893f00a 100644 --- a/packages/orm/angel_orm_test/lib/src/models/book.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/book.g.dart @@ -122,8 +122,12 @@ class BookQuery extends Query { } var model = Book( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, name: fields.contains('name') ? (row[5] as String?) : null); if (row.length > 6) { var modelOpt = AuthorQuery().parseRow(row.skip(6).take(4).toList()); @@ -285,8 +289,12 @@ class AuthorQuery extends Query { } var model = Author( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, name: fields.contains('name') ? (row[3] as String?) : null); return Optional.of(model); } diff --git a/packages/orm/angel_orm_test/lib/src/models/car.g.dart b/packages/orm/angel_orm_test/lib/src/models/car.g.dart index 80e7ffb9..60edc83f 100644 --- a/packages/orm/angel_orm_test/lib/src/models/car.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/car.g.dart @@ -91,15 +91,20 @@ class CarQuery extends Query { } var model = Car( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, make: fields.contains('make') ? (row[3] as String?) : null, description: fields.contains('description') ? (row[4] as String?) : null, familyFriendly: fields.contains('family_friendly') ? mapToBool(row[5]) : null, - recalledAt: - fields.contains('recalled_at') ? mapToDateTime(row[6]) : null); + recalledAt: fields.contains('recalled_at') + ? mapToNullableDateTime(row[6]) + : null); return Optional.of(model); } diff --git a/packages/orm/angel_orm_test/lib/src/models/custom_expr.g.dart b/packages/orm/angel_orm_test/lib/src/models/custom_expr.g.dart index 808af190..38134225 100644 --- a/packages/orm/angel_orm_test/lib/src/models/custom_expr.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/custom_expr.g.dart @@ -101,8 +101,12 @@ class NumbersQuery extends Query { } var model = Numbers( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, two: fields.contains('two') ? (row[3] as int?) : null); return Optional.of(model); } @@ -218,8 +222,12 @@ class AlphabetQuery extends Query { } var model = Alphabet( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, value: fields.contains('value') ? (row[3] as String?) : null); if (row.length > 5) { var modelOpt = NumbersQuery().parseRow(row.skip(5).take(4).toList()); 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 2a40096d..65f70b26 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 @@ -81,8 +81,12 @@ class HasCarQuery extends Query { } var model = HasCar( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, type: fields.contains('type') ? row[3] == null ? null diff --git a/packages/orm/angel_orm_test/lib/src/models/leg.g.dart b/packages/orm/angel_orm_test/lib/src/models/leg.g.dart index 336689eb..d01cb636 100644 --- a/packages/orm/angel_orm_test/lib/src/models/leg.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/leg.g.dart @@ -110,8 +110,12 @@ class LegQuery extends Query { } var model = Leg( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, name: fields.contains('name') ? (row[3] as String?) : null); if (row.length > 4) { var modelOpt = FootQuery().parseRow(row.skip(4).take(5).toList()); @@ -239,8 +243,12 @@ class FootQuery extends Query { } var model = Foot( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, legId: fields.contains('leg_id') ? (row[3] as int?) : null, nToes: fields.contains('n_toes') ? mapToDouble(row[4]) : null); return Optional.of(model); diff --git a/packages/orm/angel_orm_test/lib/src/models/order.g.dart b/packages/orm/angel_orm_test/lib/src/models/order.g.dart index 5fd06694..cdf5f1a8 100644 --- a/packages/orm/angel_orm_test/lib/src/models/order.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/order.g.dart @@ -115,10 +115,16 @@ class OrderQuery extends Query { } var model = Order( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, employeeId: fields.contains('employee_id') ? (row[4] as int?) : null, - orderDate: fields.contains('order_date') ? mapToDateTime(row[5]) : null, + orderDate: fields.contains('order_date') + ? mapToNullableDateTime(row[5]) + : null, shipperId: fields.contains('shipper_id') ? (row[6] as int?) : null); if (row.length > 7) { var modelOpt = CustomerQuery().parseRow(row.skip(7).take(3).toList()); @@ -284,9 +290,12 @@ class CustomerQuery extends Query { } var model = Customer( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: - fields.contains('updated_at') ? mapToDateTime(row[2]) : null); + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null); return Optional.of(model); } diff --git a/packages/orm/angel_orm_test/lib/src/models/person.g.dart b/packages/orm/angel_orm_test/lib/src/models/person.g.dart index f76b4bee..55d2a424 100644 --- a/packages/orm/angel_orm_test/lib/src/models/person.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/person.g.dart @@ -82,8 +82,12 @@ class PersonQuery extends Query { } var model = Person( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, name: fields.contains('name') ? (row[3] as String?) : null, age: fields.contains('age') ? (row[4] as int?) : null); return Optional.of(model); diff --git a/packages/orm/angel_orm_test/lib/src/models/person_order.g.dart b/packages/orm/angel_orm_test/lib/src/models/person_order.g.dart index 04ce92cb..069b75a2 100644 --- a/packages/orm/angel_orm_test/lib/src/models/person_order.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/person_order.g.dart @@ -92,8 +92,12 @@ class PersonOrderQuery extends Query { } var model = PersonOrder( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, personId: fields.contains('person_id') ? (row[3] as int?) : null, name: fields.contains('name') ? (row[4] as String?) : null, price: fields.contains('price') ? mapToDouble(row[5]) : null, @@ -255,8 +259,12 @@ class OrderWithPersonInfoQuery } var model = OrderWithPersonInfo( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, name: fields.contains('name') ? (row[3] as String?) : null, price: fields.contains('price') ? mapToDouble(row[4]) : null, deleted: fields.contains('deleted') ? mapToBool(row[5]) : null, diff --git a/packages/orm/angel_orm_test/lib/src/models/tree.g.dart b/packages/orm/angel_orm_test/lib/src/models/tree.g.dart index ea1b4063..1555e35e 100644 --- a/packages/orm/angel_orm_test/lib/src/models/tree.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/tree.g.dart @@ -110,8 +110,12 @@ class TreeQuery extends Query { } var model = Tree( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, rings: fields.contains('rings') ? (row[3] as int?) : null); if (row.length > 4) { var modelOpt = FruitQuery().parseRow(row.skip(4).take(5).toList()); @@ -299,8 +303,12 @@ class FruitQuery extends Query { } var model = Fruit( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, treeId: fields.contains('tree_id') ? (row[3] as int?) : null, commonName: fields.contains('common_name') ? (row[4] as String?) : null); diff --git a/packages/orm/angel_orm_test/lib/src/models/unorthodox.g.dart b/packages/orm/angel_orm_test/lib/src/models/unorthodox.g.dart index 91446563..cbdfa9bc 100644 --- a/packages/orm/angel_orm_test/lib/src/models/unorthodox.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/unorthodox.g.dart @@ -486,8 +486,12 @@ class SongQuery extends Query { } var model = Song( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, weirdJoinId: fields.contains('weird_join_id') ? (row[3] as int?) : null, title: fields.contains('title') ? (row[4] as String?) : null); return Optional.of(model); diff --git a/packages/orm/angel_orm_test/lib/src/models/user.g.dart b/packages/orm/angel_orm_test/lib/src/models/user.g.dart index 7e7a43bb..d9bc91a4 100644 --- a/packages/orm/angel_orm_test/lib/src/models/user.g.dart +++ b/packages/orm/angel_orm_test/lib/src/models/user.g.dart @@ -127,8 +127,12 @@ class UserQuery extends Query { } var model = User( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, username: fields.contains('username') ? (row[3] as String?) : null, password: fields.contains('password') ? (row[4] as String?) : null, email: fields.contains('email') ? (row[5] as String?) : null); @@ -487,8 +491,12 @@ class RoleQuery extends Query { } var model = Role( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, - updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, + createdAt: fields.contains('created_at') + ? mapToNullableDateTime(row[1]) + : null, + updatedAt: fields.contains('updated_at') + ? mapToNullableDateTime(row[2]) + : null, name: fields.contains('name') ? (row[3] as String?) : null); if (row.length > 4) { var modelOpt = UserQuery().parseRow(row.skip(4).take(6).toList());