diff --git a/packages/orm/angel_orm_postgres/pubspec.yaml b/packages/orm/angel_orm_postgres/pubspec.yaml index 2eb7c2d9..d66f391e 100644 --- a/packages/orm/angel_orm_postgres/pubspec.yaml +++ b/packages/orm/angel_orm_postgres/pubspec.yaml @@ -27,7 +27,7 @@ dependency_overrides: path: ../angel_orm_test # angel3_orm_generator: # path: ../angel_orm_generator -# angel3_orm: -# path: ../angel_orm + angel3_orm: + path: ../angel_orm angel3_migration: path: ../angel_migration diff --git a/packages/orm/angel_orm_postgres/test/common.dart b/packages/orm/angel_orm_postgres/test/common.dart index 4257eae9..664469ec 100644 --- a/packages/orm/angel_orm_postgres/test/common.dart +++ b/packages/orm/angel_orm_postgres/test/common.dart @@ -36,7 +36,42 @@ Future connectToPostgres(Iterable schemas) async { // Run sql to create the tables for (var s in schemas) { - await conn.execute(await File('test/migrations/$s.sql').readAsString()); + var rawQueryString = await File('test/migrations/$s.sql').readAsString(); + print("Raw SQL Query: $rawQueryString"); + //await conn.execute(queryString); + + // Split the queries and execute them + var stringLen = rawQueryString.length; + var index = 0; + while (index < stringLen) { + index = rawQueryString.indexOf(";"); + if (index < 0) { + break; + } + var query = rawQueryString.substring(0, index); + print("SQL Query: $query;"); + await conn.execute("$query;"); + + index++; + if (index < stringLen) { + var tempString = rawQueryString.substring(index).trim(); + rawQueryString = tempString; + stringLen = rawQueryString.length; + index = 0; + } + } + /* + var queryString = rawQueryString.replaceAll("\n", " "); + print("Raw Query: $queryString"); + var queries = queryString.split(';'); + for (var rawQuery in queries) { + var query = rawQuery.trim(); + if (query.isNotEmpty) { + print("SQL Query: $query;"); + await conn.execute("$query;"); + } + } + */ } return PostgreSqlExecutor(conn, logger: Logger.root); diff --git a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart index 0acfc03f..68941fd4 100644 --- a/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart +++ b/packages/orm/angel_orm_test/lib/src/custom_expr_test.dart @@ -10,8 +10,11 @@ void customExprTests(FutureOr Function() createExecutor, close ??= (_) => null; + var hasExecutor = false; + setUp(() async { executor = await createExecutor(); + hasExecutor = true; var now = DateTime.now(); var nQuery = NumbersQuery(); @@ -25,7 +28,7 @@ void customExprTests(FutureOr Function() createExecutor, }); tearDown(() { - if (close != null) { + if (hasExecutor && close != null) { close(executor); } }); diff --git a/packages/orm/angel_orm_test/pubspec.yaml b/packages/orm/angel_orm_test/pubspec.yaml index ca73e7e3..4b0fc529 100644 --- a/packages/orm/angel_orm_test/pubspec.yaml +++ b/packages/orm/angel_orm_test/pubspec.yaml @@ -19,7 +19,7 @@ dev_dependencies: angel3_framework: ^8.0.0 build_runner: ^2.4.0 lints: ^3.0.0 -# dependency_overrides: +dependency_overrides: # angel3_container: # path: ../../container/angel_container # angel3_framework: @@ -36,8 +36,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 # angel3_orm_generator: