From 370df62fb63c4152ed63f79bcea4069a6b446017 Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Wed, 5 May 2021 23:29:41 +0800 Subject: [PATCH] Update test cases --- CHANGELOG.md | 2 +- packages/orm/angel_orm/lib/src/join_builder.dart | 9 ++++++--- packages/orm/angel_orm/lib/src/query.dart | 9 +++++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 09ba18b6..29e3c27e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,7 +37,7 @@ * Migrated angel_orm_generator to 4.0.0 (0/0 tests passed) * Migrated angel_migration_runner to 3.0.0 (0/0 tests passed) * Migrated angel_orm_test to 3.0.0 (0/0 tests passed) -* Migrated angel_orm_postgres to 3.0.0 (44/54 tests passed) +* Migrated angel_orm_postgres to 3.0.0 (45/54 tests passed) * Update orm-sdk-2.12.x boilerplate (in progress) <= Milestone 2 diff --git a/packages/orm/angel_orm/lib/src/join_builder.dart b/packages/orm/angel_orm/lib/src/join_builder.dart index d14305f8..19c2f99b 100644 --- a/packages/orm/angel_orm/lib/src/join_builder.dart +++ b/packages/orm/angel_orm/lib/src/join_builder.dart @@ -10,7 +10,7 @@ class JoinBuilder { /// A callback to produces the expression to join against, i.e. /// a table name, or the result of compiling a query. - final String? Function() to; + final String Function() to; final List additionalFields; JoinBuilder(this.type, this.from, this.to, this.key, this.value, @@ -39,9 +39,12 @@ class JoinBuilder { return right; } - String? compile(Set? trampoline) { + String compile(Set? trampoline) { var compiledTo = to(); - if (compiledTo == null) return null; + //if (compiledTo == null) return null; + if (compiledTo == '') { + return ''; + } var b = StringBuffer(); var left = '${from.tableName}.$key'; var right = fieldName; diff --git a/packages/orm/angel_orm/lib/src/query.dart b/packages/orm/angel_orm/lib/src/query.dart index 426215b9..a31cdbfd 100644 --- a/packages/orm/angel_orm/lib/src/query.dart +++ b/packages/orm/angel_orm/lib/src/query.dart @@ -148,6 +148,9 @@ abstract class Query extends QueryBase { return () { var c = tableName.compile(trampoline); //if (c == null) return c; + if (c == '') { + return c; + } return '($c)'; }; } else { @@ -241,7 +244,8 @@ abstract class Query extends QueryBase { // One table MAY appear multiple times in a query. if (!canCompile(trampoline)) { //return null; - throw Exception('One table appear multiple times in a query'); + //throw Exception('One table appear multiple times in a query'); + return ''; } includeTableName = includeTableName || _joins.isNotEmpty; @@ -285,7 +289,8 @@ abstract class Query extends QueryBase { })); _joins.forEach((j) { var c = compiledJoins[j] = j.compile(trampoline); - if (c != null) { + //if (c != null) { + if (c != '') { var additional = j.additionalFields.map(j.nameFor).toList(); f.addAll(additional); } else {