diff --git a/packages/orm/angel_orm/CHANGELOG.md b/packages/orm/angel_orm/CHANGELOG.md index bebecb69..002b8d51 100644 --- a/packages/orm/angel_orm/CHANGELOG.md +++ b/packages/orm/angel_orm/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.1 + +* Added `mapToDateTime` + ## 6.0.0 * Updated to SDK 2.16.x diff --git a/packages/orm/angel_orm/lib/src/util.dart b/packages/orm/angel_orm/lib/src/util.dart index 3a4352c6..74421b74 100644 --- a/packages/orm/angel_orm/lib/src/util.dart +++ b/packages/orm/angel_orm/lib/src/util.dart @@ -19,3 +19,27 @@ String mapToText(dynamic value) { } return value; } + +DateTime? mapToDateTime(dynamic value) { + if (value == null) { + return value; + } + if (value is String) { + return DateTime.tryParse(value); + } + return value; +} + +double mapToDouble(dynamic value) { + if (value == null) { + return 0.0; + } + if (value is String) { + return double.tryParse(value) ?? 0.0; + } + + if (value is! double) { + return 0.0; + } + return value; +} diff --git a/packages/orm/angel_orm/pubspec.yaml b/packages/orm/angel_orm/pubspec.yaml index 7a22c6d9..9d489a47 100644 --- a/packages/orm/angel_orm/pubspec.yaml +++ b/packages/orm/angel_orm/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_orm -version: 6.0.0 +version: 6.0.1 description: Runtime support for Angel3 ORM. Includes base classes for queries. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm diff --git a/packages/orm/angel_orm_generator/CHANGELOG.md b/packages/orm/angel_orm_generator/CHANGELOG.md index 7be9b00b..1ddfef75 100644 --- a/packages/orm/angel_orm_generator/CHANGELOG.md +++ b/packages/orm/angel_orm_generator/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 6.0.1 + +* Fixed timestamp or date field to DateTime mapping +* Fixed double or float field to double mapping + ## 6.0.0 * Updated to SDK 2.16.x diff --git a/packages/orm/angel_orm_generator/example/main.g.dart b/packages/orm/angel_orm_generator/example/main.g.dart index 97d1d0db..c9da293d 100644 --- a/packages/orm/angel_orm_generator/example/main.g.dart +++ b/packages/orm/angel_orm_generator/example/main.g.dart @@ -93,14 +93,12 @@ class EmployeeQuery extends Query { } var model = Employee( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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') - ? double.tryParse(row[6].toString()) - : null); + salary: fields.contains('salary') ? mapToDouble(row[6]) : null); return Optional.of(model); } 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 62eb7cd5..913fab41 100644 --- a/packages/orm/angel_orm_generator/lib/src/orm_generator.dart +++ b/packages/orm/angel_orm_generator/lib/src/orm_generator.dart @@ -262,9 +262,10 @@ class OrmGenerator extends GeneratorForAnnotation { .property('decode') .call([expr.asA(refer('String'))]).asA(type); } else if (floatTypes.contains(ctx.columns[field.name]?.type)) { - expr = refer('double') - .property('tryParse') - .call([expr.property('toString').call([])]); + //expr = refer('double') + // .property('tryParse') + // .call([expr.property('toString').call([])]); + expr = refer('mapToDouble').call([expr]); } else if (fType is InterfaceType && fType.element.isEnum) { var isNull = expr.equalTo(literalNull); expr = isNull.conditional(literalNull, @@ -272,6 +273,10 @@ class OrmGenerator extends GeneratorForAnnotation { } else if (fType.isDartCoreBool) { // 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]); } else { // Generated Code: (row[i] as type?) expr = expr.asA(type); diff --git a/packages/orm/angel_orm_generator/pubspec.yaml b/packages/orm/angel_orm_generator/pubspec.yaml index cf642009..198e526b 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: 6.0.0 +version: 6.0.1 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 @@ -30,7 +30,7 @@ dev_dependencies: postgres: ^2.4.0 test: ^1.21.0 lints: ^1.0.0 -# dependency_overrides: +dependency_overrides: # angel3_container: # path: ../../container/angel_container # angel3_framework: @@ -47,8 +47,8 @@ dev_dependencies: # path: ../../serialize/angel_serialize # angel3_serialize_generator: # path: ../../serialize/angel_serialize_generator -# angel3_orm: -# path: ../angel_orm + angel3_orm: + path: ../angel_orm # angel3_migration: # path: ../angel_migration \ No newline at end of file diff --git a/packages/orm/angel_orm_mysql/CHANGELOG.md b/packages/orm/angel_orm_mysql/CHANGELOG.md index c0ad53af..36c22dfc 100644 --- a/packages/orm/angel_orm_mysql/CHANGELOG.md +++ b/packages/orm/angel_orm_mysql/CHANGELOG.md @@ -1,5 +1,10 @@ # Change Log +## 6.0.0-beta.3 + +* Updated transaction for `MariaDbExecutor` +* Updated transaction for `MySqlExecutor` + ## 6.0.0-beta.2 * Updated README diff --git a/packages/orm/angel_orm_mysql/example/main.g.dart b/packages/orm/angel_orm_mysql/example/main.g.dart index 02ae2be8..e361ec2c 100644 --- a/packages/orm/angel_orm_mysql/example/main.g.dart +++ b/packages/orm/angel_orm_mysql/example/main.g.dart @@ -81,8 +81,8 @@ class TodoQuery extends Query { } var model = Todo( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, isComplete: fields.contains('is_complete') ? mapToBool(row[3]) : null, text: fields.contains('text') ? (row[4] as String?) : null); return Optional.of(model); diff --git a/packages/orm/angel_orm_mysql/lib/src/orm_mariadb.dart b/packages/orm/angel_orm_mysql/lib/src/orm_mariadb.dart index 873fa1c8..5675a6f0 100644 --- a/packages/orm/angel_orm_mysql/lib/src/orm_mariadb.dart +++ b/packages/orm/angel_orm_mysql/lib/src/orm_mariadb.dart @@ -4,12 +4,14 @@ import 'package:logging/logging.dart'; import 'package:mysql1/mysql1.dart'; class MariaDbExecutor extends QueryExecutor { - /// An optional [Logger] to write to. - final Logger? logger; + /// An optional [Logger] print information to. A default logger will be used if not set + late Logger logger; final MySqlConnection _connection; - MariaDbExecutor(this._connection, {this.logger}); + MariaDbExecutor(this._connection, {Logger? logger}) { + this.logger = logger ?? Logger('MariaDbExecutor'); + } final Dialect _dialect = const MySQLDialect(); @@ -18,66 +20,8 @@ class MariaDbExecutor extends QueryExecutor { Future close() { return _connection.close(); - /* - if (_connection is MySqlConnection) { - return (_connection as MySqlConnection).close(); - } else { - return Future.value(); - } - */ } - /* - Future _startTransaction() { - if (_connection is Transaction) { - return Future.value(_connection as Transaction?); - } else if (_connection is MySqlConnection) { - return (_connection as MySqlConnection).begin(); - } else { - throw StateError('Connection must be transaction or connection'); - } - } - - @override - Future> query( - String tableName, String query, Map substitutionValues, - [List returningFields = const []]) { - // Change @id -> ? - for (var name in substitutionValues.keys) { - query = query.replaceAll('@$name', '?'); - } - - logger?.fine('Query: $query'); - logger?.fine('Values: $substitutionValues'); - - if (returningFields.isNotEmpty != true) { - return _connection! - .prepared(query, substitutionValues.values) - .then((results) => results.map((r) => r.toList()).toList()); - } else { - return Future(() async { - var tx = await _startTransaction(); - - try { - var writeResults = - await tx.prepared(query, substitutionValues.values); - var fieldSet = returningFields.map((s) => '`$s`').join(','); - var fetchSql = 'select $fieldSet from $tableName where id = ?;'; - logger?.fine(fetchSql); - var readResults = - await tx.prepared(fetchSql, [writeResults.insertId]); - var mapped = readResults.map((r) => r.toList()).toList(); - await tx.commit(); - return mapped; - } catch (_) { - await tx.rollback(); - rethrow; - } - }); - } - } - */ - @override Future> query( String tableName, String query, Map substitutionValues, @@ -101,9 +45,8 @@ class MariaDbExecutor extends QueryExecutor { var result = await _connection.query(query, params); query = returningQuery; - //logger?.warning('Result.insertId: ${result.insertId}'); + // logger?.warning('Result.insertId: ${result.insertId}'); // Has primary key - //if (result.insertId != 0) { if (returningQuery.endsWith('.id=?')) { params = [result.insertId]; } @@ -122,35 +65,20 @@ class MariaDbExecutor extends QueryExecutor { @override Future transaction(FutureOr Function(QueryExecutor) f) async { - return f(this); - /* - if (_connection is! MySqlConnection) { - return await f(this); - } - - await _connection.transaction((context) async { - var executor = MySqlExecutor(context, logger: logger); + T? returnValue = await _connection.transaction((ctx) async { + var conn = ctx as MySqlConnection; + try { + logger.fine('Entering transaction'); + var tx = MariaDbExecutor(conn, logger: logger); + return await f(tx); + } catch (e) { + logger.severe('Failed to run transaction', e); + rethrow; + } finally { + logger.fine('Exiting transaction'); + } }); - */ - } - /* - @override - Future transaction(FutureOr Function(QueryExecutor) f) async { - if (_connection is Transaction) { - return await f(this); - } - Transaction? tx; - try { - tx = await _startTransaction(); - var executor = MySqlExecutor(tx, logger: logger); - var result = await f(executor); - await tx.commit(); - return result; - } catch (_) { - await tx?.rollback(); - rethrow; - } + return returnValue!; } - */ } diff --git a/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart b/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart index e8e112e0..937279c3 100644 --- a/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart +++ b/packages/orm/angel_orm_mysql/lib/src/orm_mysql.dart @@ -4,12 +4,14 @@ import 'package:logging/logging.dart'; import 'package:mysql_client/mysql_client.dart'; class MySqlExecutor extends QueryExecutor { - /// An optional [Logger] to write to. - final Logger? logger; + /// An optional [Logger] to write to. A default logger will be used if not set + late Logger logger; final MySQLConnection _connection; - MySqlExecutor(this._connection, {this.logger}); + MySqlExecutor(this._connection, {Logger? logger}) { + this.logger = logger ?? Logger('MySqlExecutor'); + } final Dialect _dialect = const MySQLDialect(); @@ -18,13 +20,6 @@ class MySqlExecutor extends QueryExecutor { Future close() { return _connection.close(); - /* - if (_connection is MySqlConnection) { - return (_connection as MySqlConnection).close(); - } else { - return Future.value(); - } - */ } /* @@ -86,13 +81,23 @@ class MySqlExecutor extends QueryExecutor { // Change @id -> ? for (var name in substitutionValues.keys) { query = query.replaceAll('@$name', ':$name'); + + // Convert UTC time to local time + var value = substitutionValues[name]; + if (value is DateTime && value.isUtc) { + var t = value.toLocal(); + logger.warning('Datetime deteted: $name'); + logger.warning('Datetime: UTC -> $value, Local -> $t'); + + substitutionValues[name] = t; + } } //var params = substitutionValues.values.toList(); - var params = []; + //var params = []; - logger?.warning('Query: $query'); - logger?.warning('Values: $substitutionValues'); + logger.warning('Query: $query'); + logger.warning('Values: $substitutionValues'); //logger?.warning('Returning Query: $returningQuery'); if (returningQuery.isNotEmpty) { @@ -101,35 +106,28 @@ class MySqlExecutor extends QueryExecutor { if (query.startsWith("INSERT")) { var result = await _connection.execute(query, substitutionValues); - logger?.warning(result.lastInsertID); + logger.warning(result.lastInsertID); query = returningQuery; //logger?.warning('Result.insertId: ${result.insertId}'); // Has primary key - //if (result.insertId != 0) { if (returningQuery.endsWith('.id=?')) { query = query.replaceAll("?", ":id"); - //params = [result.lastInsertID]; substitutionValues.clear(); substitutionValues['id'] = result.lastInsertID; } } else if (query.startsWith("UPDATE")) { await _connection.execute(query, substitutionValues); query = returningQuery; - params = []; } } - logger?.warning('Query 2: $query'); - logger?.warning('Values 2: $substitutionValues'); + logger.warning('Query 2: $query'); + logger.warning('Values 2: $substitutionValues'); // Handle select return _connection.execute(query, substitutionValues).then((results) { - logger?.warning("SELECT"); - //for (var element in results.cols) { - // print( - // '${element.name} ${element.type.toString()} ${element.runtimeType.toString()}'); - //} + logger.warning("SELECT"); return results.rows.map((r) => r.typedAssoc().values.toList()).toList(); }); @@ -137,17 +135,22 @@ class MySqlExecutor extends QueryExecutor { @override Future transaction(FutureOr Function(QueryExecutor) f) async { - logger?.warning("Transaction"); - return f(this); - /* - if (_connection is! MySqlConnection) { - return await f(this); - } + logger.warning("Transaction"); - await _connection.transaction((context) async { - var executor = MySqlExecutor(context, logger: logger); + T? returnValue = await _connection.transactional((ctx) async { + try { + logger.fine('Entering transaction'); + var tx = MySqlExecutor(ctx, logger: logger); + return await f(tx); + } catch (e) { + logger.severe('Failed to run transaction', e); + rethrow; + } finally { + logger.fine('Exiting transaction'); + } }); - */ + + return returnValue!; } /* @override diff --git a/packages/orm/angel_orm_mysql/pubspec.yaml b/packages/orm/angel_orm_mysql/pubspec.yaml index 3a77498a..d5477ac2 100644 --- a/packages/orm/angel_orm_mysql/pubspec.yaml +++ b/packages/orm/angel_orm_mysql/pubspec.yaml @@ -1,5 +1,5 @@ name: angel3_orm_mysql -version: 6.0.0-beta.2 +version: 6.0.0-beta.3 description: MySQL support for Angel3 ORM. Includes functionality for querying and transactions. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql @@ -9,7 +9,7 @@ dependencies: angel3_orm: ^6.0.0 logging: ^1.0.0 mysql1: ^0.19.0 - mysql_client: ^0.0.11 + mysql_client: ^0.0.15 optional: ^6.0.0 dev_dependencies: angel3_orm_generator: ^6.0.0 @@ -17,18 +17,18 @@ dev_dependencies: build_runner: ^2.0.1 test: ^1.21.0 lints: ^1.0.0 -# dependency_overrides: +dependency_overrides: # angel3_serialize: # path: ../../serialize/angel_serialize # angel3_serialize_generator: # path: ../../serialize/angel_serialize_generator # angel3_model: # path: ../../model -# angel3_orm_test: -# path: ../angel_orm_test -# angel3_orm: -# path: ../angel_orm -# angel3_migration: -# path: ../angel_migration -# angel3_orm_generator: -# path: ../angel_orm_generator + angel3_orm_test: + path: ../angel_orm_test + angel3_orm: + path: ../angel_orm + angel3_orm_generator: + path: ../angel_orm_generator +# angel3_migration: +# path: ../angel_migration diff --git a/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart b/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart index 1314afec..9dbb7dc3 100644 --- a/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart +++ b/packages/orm/angel_orm_postgres/lib/src/orm_postgres.dart @@ -9,7 +9,8 @@ import 'package:postgres/postgres.dart'; class PostgreSqlExecutor extends QueryExecutor { final PostgreSQLExecutionContext _connection; - /// An optional [Logger] to print information to. + /// An optional [Logger] to print information to. A default logger will be used + /// if not set late Logger logger; PostgreSqlExecutor(this._connection, {Logger? logger}) { diff --git a/packages/orm/angel_orm_postgres/pubspec.yaml b/packages/orm/angel_orm_postgres/pubspec.yaml index f2338b82..cce84d47 100644 --- a/packages/orm/angel_orm_postgres/pubspec.yaml +++ b/packages/orm/angel_orm_postgres/pubspec.yaml @@ -16,14 +16,14 @@ dev_dependencies: angel3_orm_test: ^6.0.0 test: ^1.21.0 lints: ^1.0.0 -# dependency_overrides: +dependency_overrides: # angel3_serialize: # path: ../../serialize/angel_serialize # angel3_model: # path: ../../model -# angel3_orm_test: -# path: ../angel_orm_test -# angel3_orm: -# path: ../angel_orm + angel3_orm_test: + path: ../angel_orm_test + angel3_orm: + path: ../angel_orm # angel3_migration: # path: ../angel_migration diff --git a/packages/orm/angel_orm_test/CHANGELOG.md b/packages/orm/angel_orm_test/CHANGELOG.md index 15099c77..72ee8360 100644 --- a/packages/orm/angel_orm_test/CHANGELOG.md +++ b/packages/orm/angel_orm_test/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 6.0.1 + +* Updated generated test cases + ## 6.0.0 * Updated to SDK 2.16.x 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 e7342120..7d954e42 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,8 @@ class BookQuery extends Query { } var model = Book( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 +285,8 @@ class AuthorQuery extends Query { } var model = Author( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 fa0a8333..80e7ffb9 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,15 @@ class CarQuery extends Query { } var model = Car( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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') ? (row[6] as DateTime?) : null); + fields.contains('recalled_at') ? mapToDateTime(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 1993d623..808af190 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,8 @@ class NumbersQuery extends Query { } var model = Numbers( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, two: fields.contains('two') ? (row[3] as int?) : null); return Optional.of(model); } @@ -218,8 +218,8 @@ class AlphabetQuery extends Query { } var model = Alphabet( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 fde5d0f6..2a40096d 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,8 @@ class HasCarQuery extends Query { } var model = HasCar( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 5117f6b4..cd7a7a3b 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 @@ -111,8 +111,8 @@ class LegQuery extends Query { } var model = Leg( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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()); @@ -240,12 +240,10 @@ class FootQuery extends Query { } var model = Foot( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, legId: fields.contains('leg_id') ? (row[3] as int?) : null, - nToes: fields.contains('n_toes') - ? double.tryParse(row[4].toString()) - : 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 b5845d6b..5fd06694 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,10 @@ class OrderQuery extends Query { } var model = Order( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, employeeId: fields.contains('employee_id') ? (row[4] as int?) : null, - orderDate: fields.contains('order_date') ? (row[5] as DateTime?) : null, + orderDate: fields.contains('order_date') ? mapToDateTime(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 +284,9 @@ class CustomerQuery extends Query { } var model = Customer( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, updatedAt: - fields.contains('updated_at') ? (row[2] as DateTime?) : null); + fields.contains('updated_at') ? mapToDateTime(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 2f7ccd44..b18bc29b 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,8 @@ class PersonQuery extends Query { } var model = Person( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 0f73ca95..f02b83db 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 @@ -93,13 +93,11 @@ class PersonOrderQuery extends Query { } var model = PersonOrder( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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') - ? double.tryParse(row[5].toString()) - : null, + price: fields.contains('price') ? mapToDouble(row[5]) : null, deleted: fields.contains('deleted') ? mapToBool(row[6]) : null); return Optional.of(model); } @@ -258,12 +256,10 @@ class OrderWithPersonInfoQuery } var model = OrderWithPersonInfo( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(row[2]) : null, name: fields.contains('name') ? (row[3] as String?) : null, - price: fields.contains('price') - ? double.tryParse(row[4].toString()) - : null, + price: fields.contains('price') ? mapToDouble(row[4]) : null, deleted: fields.contains('deleted') ? mapToBool(row[5]) : null, personName: fields.contains('person_name') ? (row[6] as String?) : null, personAge: fields.contains('person_age') ? (row[7] as int?) : 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 c4a34e37..ea1b4063 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,8 @@ class TreeQuery extends Query { } var model = Tree( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 +299,8 @@ class FruitQuery extends Query { } var model = Fruit( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 731da605..91446563 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,8 @@ class SongQuery extends Query { } var model = Song( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 f88d37ee..7e7a43bb 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,8 @@ class UserQuery extends Query { } var model = User( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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 +487,8 @@ class RoleQuery extends Query { } var model = Role( id: fields.contains('id') ? row[0].toString() : null, - createdAt: fields.contains('created_at') ? (row[1] as DateTime?) : null, - updatedAt: fields.contains('updated_at') ? (row[2] as DateTime?) : null, + createdAt: fields.contains('created_at') ? mapToDateTime(row[1]) : null, + updatedAt: fields.contains('updated_at') ? mapToDateTime(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()); diff --git a/packages/orm/angel_orm_test/pubspec.yaml b/packages/orm/angel_orm_test/pubspec.yaml index 293df0c6..204c1ffc 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: 6.0.0 +version: 6.0.1 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 @@ -19,26 +19,26 @@ dev_dependencies: angel3_framework: ^6.0.0 build_runner: ^2.0.1 lints: ^1.0.0 -# dependency_overrides: -# angel3_container: -# path: ../../container/angel_container -# angel3_framework: -# path: ../../framework -# angel3_http_exception: -# path: ../../http_exception -# angel3_model: -# path: ../../model -# angel3_route: -# path: ../../route -# angel3_mock_request: -# path: ../../mock_request -# angel3_serialize: -# path: ../../serialize/angel_serialize -# angel3_serialize_generator: -# path: ../../serialize/angel_serialize_generator -# angel3_orm: -# path: ../angel_orm -# angel3_migration: -# path: ../angel_migration -# angel3_orm_generator: -# path: ../angel_orm_generator +dependency_overrides: + # angel3_container: + # path: ../../container/angel_container + # angel3_framework: + # path: ../../framework + # angel3_http_exception: + # path: ../../http_exception + # angel3_model: + # path: ../../model + # angel3_route: + # path: ../../route + # angel3_mock_request: + # path: ../../mock_request + # angel3_serialize: + # path: ../../serialize/angel_serialize + # angel3_serialize_generator: + # path: ../../serialize/angel_serialize_generator + angel3_orm: + path: ../angel_orm + # angel3_migration: + # path: ../angel_migration + angel3_orm_generator: + path: ../angel_orm_generator