Update test cases

This commit is contained in:
thomashii@dukefirehawk.com 2021-05-05 23:29:41 +08:00
parent 0addba99d3
commit 370df62fb6
3 changed files with 14 additions and 6 deletions

View file

@ -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

View file

@ -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<String> additionalFields;
JoinBuilder(this.type, this.from, this.to, this.key, this.value,
@ -39,9 +39,12 @@ class JoinBuilder {
return right;
}
String? compile(Set<String>? trampoline) {
String compile(Set<String>? 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;

View file

@ -148,6 +148,9 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
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<T, Where extends QueryWhere> extends QueryBase<T> {
// 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<T, Where extends QueryWhere> extends QueryBase<T> {
}));
_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 {