From f4b7512c5182203d75d869cc3418a9dbfeb6846d Mon Sep 17 00:00:00 2001 From: Tobe O Date: Sat, 17 Aug 2019 18:53:27 -0400 Subject: [PATCH] Regen test models --- .../lib/src/orm_generator.dart | 2 +- angel_orm_test/lib/src/models/book.g.dart | 17 +++++- .../lib/src/models/email_indexed.g.dart | 34 +++++++++-- angel_orm_test/lib/src/models/leg.g.dart | 8 ++- angel_orm_test/lib/src/models/order.g.dart | 9 ++- angel_orm_test/lib/src/models/tree.g.dart | 8 ++- .../lib/src/models/unorthodox.g.dart | 60 ++++++++++++++++--- angel_orm_test/lib/src/models/user.g.dart | 32 ++++++++-- 8 files changed, 149 insertions(+), 21 deletions(-) diff --git a/angel_orm_generator/lib/src/orm_generator.dart b/angel_orm_generator/lib/src/orm_generator.dart index 05daa59b..b5a305c0 100644 --- a/angel_orm_generator/lib/src/orm_generator.dart +++ b/angel_orm_generator/lib/src/orm_generator.dart @@ -318,7 +318,7 @@ class OrmGenerator extends GeneratorForAnnotation { var queryInstantiation = foreignQueryType .newInstance([], {'trampoline': refer('trampoline')}); joinArgs.insert( - 0, queryInstantiation.assign(refer('_$fieldName'))); + 0, refer('_$fieldName').assign(queryInstantiation)); b.addExpression(refer('leftJoin').call(joinArgs, { 'additionalFields': diff --git a/angel_orm_test/lib/src/models/book.g.dart b/angel_orm_test/lib/src/models/book.g.dart index acbfb238..dc6607f0 100644 --- a/angel_orm_test/lib/src/models/book.g.dart +++ b/angel_orm_test/lib/src/models/book.g.dart @@ -55,10 +55,11 @@ class BookQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = BookQueryWhere(this); - leftJoin('authors', 'author_id', 'id', + leftJoin(_author = AuthorQuery(trampoline: trampoline), 'author_id', 'id', additionalFields: const ['id', 'created_at', 'updated_at', 'name'], trampoline: trampoline); - leftJoin('authors', 'partner_author_id', 'id', + leftJoin(_partnerAuthor = AuthorQuery(trampoline: trampoline), + 'partner_author_id', 'id', additionalFields: const ['id', 'created_at', 'updated_at', 'name'], trampoline: trampoline); } @@ -68,6 +69,10 @@ class BookQuery extends Query { BookQueryWhere _where; + AuthorQuery _author; + + AuthorQuery _partnerAuthor; + @override get casts { return {}; @@ -122,6 +127,14 @@ class BookQuery extends Query { deserialize(List row) { return parseRow(row); } + + AuthorQuery get author { + return _author; + } + + AuthorQuery get partnerAuthor { + return _partnerAuthor; + } } class BookQueryWhere extends QueryWhere { diff --git a/angel_orm_test/lib/src/models/email_indexed.g.dart b/angel_orm_test/lib/src/models/email_indexed.g.dart index f8fc5422..d61b85ee 100644 --- a/angel_orm_test/lib/src/models/email_indexed.g.dart +++ b/angel_orm_test/lib/src/models/email_indexed.g.dart @@ -64,7 +64,8 @@ class RoleQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = RoleQueryWhere(this); - leftJoin(RoleUserQuery(trampoline: trampoline), 'role', 'role_role', + leftJoin( + _users = RoleUserQuery(trampoline: trampoline), 'role', 'role_role', additionalFields: const ['email', 'name', 'password'], trampoline: trampoline); } @@ -74,6 +75,8 @@ class RoleQuery extends Query { RoleQueryWhere _where; + RoleUserQuery _users; + @override get casts { return {}; @@ -116,6 +119,10 @@ class RoleQuery extends Query { return parseRow(row); } + RoleUserQuery get users { + return _users; + } + @override bool canCompile(trampoline) { return (!(trampoline.contains('roles') && @@ -213,9 +220,9 @@ class RoleUserQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = RoleUserQueryWhere(this); - leftJoin('roles', 'role_role', 'role', + leftJoin(_role = RoleQuery(trampoline: trampoline), 'role_role', 'role', additionalFields: const ['role'], trampoline: trampoline); - leftJoin('users', 'user_email', 'email', + leftJoin(_user = UserQuery(trampoline: trampoline), 'user_email', 'email', additionalFields: const ['email', 'name', 'password'], trampoline: trampoline); } @@ -225,6 +232,10 @@ class RoleUserQuery extends Query { RoleUserQueryWhere _where; + RoleQuery _role; + + UserQuery _user; + @override get casts { return {}; @@ -268,6 +279,14 @@ class RoleUserQuery extends Query { deserialize(List row) { return parseRow(row); } + + RoleQuery get role { + return _role; + } + + UserQuery get user { + return _user; + } } class RoleUserQueryWhere extends QueryWhere { @@ -316,7 +335,8 @@ class UserQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = UserQueryWhere(this); - leftJoin(RoleUserQuery(trampoline: trampoline), 'email', 'user_email', + leftJoin( + _roles = RoleUserQuery(trampoline: trampoline), 'email', 'user_email', additionalFields: const ['role'], trampoline: trampoline); } @@ -325,6 +345,8 @@ class UserQuery extends Query { UserQueryWhere _where; + RoleUserQuery _roles; + @override get casts { return {}; @@ -370,6 +392,10 @@ class UserQuery extends Query { return parseRow(row); } + RoleUserQuery get roles { + return _roles; + } + @override bool canCompile(trampoline) { return (!(trampoline.contains('users') && diff --git a/angel_orm_test/lib/src/models/leg.g.dart b/angel_orm_test/lib/src/models/leg.g.dart index 28042af5..e3e2079d 100644 --- a/angel_orm_test/lib/src/models/leg.g.dart +++ b/angel_orm_test/lib/src/models/leg.g.dart @@ -50,7 +50,7 @@ class LegQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = LegQueryWhere(this); - leftJoin('feet', 'id', 'leg_id', + leftJoin(_foot = FootQuery(trampoline: trampoline), 'id', 'leg_id', additionalFields: const [ 'id', 'created_at', @@ -66,6 +66,8 @@ class LegQuery extends Query { LegQueryWhere _where; + FootQuery _foot; + @override get casts { return {}; @@ -109,6 +111,10 @@ class LegQuery extends Query { deserialize(List row) { return parseRow(row); } + + FootQuery get foot { + return _foot; + } } class LegQueryWhere extends QueryWhere { diff --git a/angel_orm_test/lib/src/models/order.g.dart b/angel_orm_test/lib/src/models/order.g.dart index b18adb9c..25dfb8f6 100644 --- a/angel_orm_test/lib/src/models/order.g.dart +++ b/angel_orm_test/lib/src/models/order.g.dart @@ -53,7 +53,8 @@ class OrderQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = OrderQueryWhere(this); - leftJoin('customers', 'customer_id', 'id', + leftJoin( + _customer = CustomerQuery(trampoline: trampoline), 'customer_id', 'id', additionalFields: const ['id', 'created_at', 'updated_at'], trampoline: trampoline); } @@ -63,6 +64,8 @@ class OrderQuery extends Query { OrderQueryWhere _where; + CustomerQuery _customer; + @override get casts { return {}; @@ -116,6 +119,10 @@ class OrderQuery extends Query { deserialize(List row) { return parseRow(row); } + + CustomerQuery get customer { + return _customer; + } } class OrderQueryWhere extends QueryWhere { diff --git a/angel_orm_test/lib/src/models/tree.g.dart b/angel_orm_test/lib/src/models/tree.g.dart index 9adfb803..b12e8b9e 100644 --- a/angel_orm_test/lib/src/models/tree.g.dart +++ b/angel_orm_test/lib/src/models/tree.g.dart @@ -50,7 +50,7 @@ class TreeQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = TreeQueryWhere(this); - leftJoin(FruitQuery(trampoline: trampoline), 'id', 'tree_id', + leftJoin(_fruits = FruitQuery(trampoline: trampoline), 'id', 'tree_id', additionalFields: const [ 'id', 'created_at', @@ -66,6 +66,8 @@ class TreeQuery extends Query { TreeQueryWhere _where; + FruitQuery _fruits; + @override get casts { return {}; @@ -112,6 +114,10 @@ class TreeQuery extends Query { return parseRow(row); } + FruitQuery get fruits { + return _fruits; + } + @override get(QueryExecutor executor) { return super.get(executor).then((result) { diff --git a/angel_orm_test/lib/src/models/unorthodox.g.dart b/angel_orm_test/lib/src/models/unorthodox.g.dart index 400d5da6..9042596c 100644 --- a/angel_orm_test/lib/src/models/unorthodox.g.dart +++ b/angel_orm_test/lib/src/models/unorthodox.g.dart @@ -187,9 +187,10 @@ class WeirdJoinQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = WeirdJoinQueryWhere(this); - leftJoin('unorthodoxes', 'join_name', 'name', + leftJoin(_unorthodox = UnorthodoxQuery(trampoline: trampoline), 'join_name', + 'name', additionalFields: const ['name'], trampoline: trampoline); - leftJoin('songs', 'id', 'weird_join_id', + leftJoin(_song = SongQuery(trampoline: trampoline), 'id', 'weird_join_id', additionalFields: const [ 'id', 'created_at', @@ -198,9 +199,10 @@ class WeirdJoinQuery extends Query { 'title' ], trampoline: trampoline); - leftJoin(NumbaQuery(trampoline: trampoline), 'id', 'parent', + leftJoin(_numbas = NumbaQuery(trampoline: trampoline), 'id', 'parent', additionalFields: const ['i', 'parent'], trampoline: trampoline); - leftJoin(FooPivotQuery(trampoline: trampoline), 'id', 'weird_join_id', + leftJoin( + _foos = FooPivotQuery(trampoline: trampoline), 'id', 'weird_join_id', additionalFields: const ['bar'], trampoline: trampoline); } @@ -209,6 +211,14 @@ class WeirdJoinQuery extends Query { WeirdJoinQueryWhere _where; + UnorthodoxQuery _unorthodox; + + SongQuery _song; + + NumbaQuery _numbas; + + FooPivotQuery _foos; + @override get casts { return {}; @@ -265,6 +275,22 @@ class WeirdJoinQuery extends Query { return parseRow(row); } + UnorthodoxQuery get unorthodox { + return _unorthodox; + } + + SongQuery get song { + return _song; + } + + NumbaQuery get numbas { + return _numbas; + } + + FooPivotQuery get foos { + return _foos; + } + @override bool canCompile(trampoline) { return (!(trampoline.contains('weird_joins') && @@ -579,7 +605,8 @@ class FooQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = FooQueryWhere(this); - leftJoin(FooPivotQuery(trampoline: trampoline), 'bar', 'foo_bar', + leftJoin( + _weirdJoins = FooPivotQuery(trampoline: trampoline), 'bar', 'foo_bar', additionalFields: const ['id', 'join_name'], trampoline: trampoline); } @@ -588,6 +615,8 @@ class FooQuery extends Query { FooQueryWhere _where; + FooPivotQuery _weirdJoins; + @override get casts { return {}; @@ -630,6 +659,10 @@ class FooQuery extends Query { return parseRow(row); } + FooPivotQuery get weirdJoins { + return _weirdJoins; + } + @override bool canCompile(trampoline) { return (!(trampoline.contains('foos') && @@ -727,9 +760,10 @@ class FooPivotQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = FooPivotQueryWhere(this); - leftJoin('weird_joins', 'weird_join_id', 'id', + leftJoin(_weirdJoin = WeirdJoinQuery(trampoline: trampoline), + 'weird_join_id', 'id', additionalFields: const ['id', 'join_name'], trampoline: trampoline); - leftJoin('foos', 'foo_bar', 'bar', + leftJoin(_foo = FooQuery(trampoline: trampoline), 'foo_bar', 'bar', additionalFields: const ['bar'], trampoline: trampoline); } @@ -738,6 +772,10 @@ class FooPivotQuery extends Query { FooPivotQueryWhere _where; + WeirdJoinQuery _weirdJoin; + + FooQuery _foo; + @override get casts { return {}; @@ -781,6 +819,14 @@ class FooPivotQuery extends Query { deserialize(List row) { return parseRow(row); } + + WeirdJoinQuery get weirdJoin { + return _weirdJoin; + } + + FooQuery get foo { + return _foo; + } } class FooPivotQueryWhere extends QueryWhere { diff --git a/angel_orm_test/lib/src/models/user.g.dart b/angel_orm_test/lib/src/models/user.g.dart index 19dade2e..c5fd1239 100644 --- a/angel_orm_test/lib/src/models/user.g.dart +++ b/angel_orm_test/lib/src/models/user.g.dart @@ -66,7 +66,7 @@ class UserQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = UserQueryWhere(this); - leftJoin(RoleUserQuery(trampoline: trampoline), 'id', 'user_id', + leftJoin(_roles = RoleUserQuery(trampoline: trampoline), 'id', 'user_id', additionalFields: const ['id', 'created_at', 'updated_at', 'name'], trampoline: trampoline); } @@ -76,6 +76,8 @@ class UserQuery extends Query { UserQueryWhere _where; + RoleUserQuery _roles; + @override get casts { return {}; @@ -131,6 +133,10 @@ class UserQuery extends Query { return parseRow(row); } + RoleUserQuery get roles { + return _roles; + } + @override bool canCompile(trampoline) { return (!(trampoline.contains('users') && @@ -272,10 +278,10 @@ class RoleUserQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = RoleUserQueryWhere(this); - leftJoin('roles', 'role_id', 'id', + leftJoin(_role = RoleQuery(trampoline: trampoline), 'role_id', 'id', additionalFields: const ['id', 'created_at', 'updated_at', 'name'], trampoline: trampoline); - leftJoin('users', 'user_id', 'id', + leftJoin(_user = UserQuery(trampoline: trampoline), 'user_id', 'id', additionalFields: const [ 'id', 'created_at', @@ -292,6 +298,10 @@ class RoleUserQuery extends Query { RoleUserQueryWhere _where; + RoleQuery _role; + + UserQuery _user; + @override get casts { return {}; @@ -335,6 +345,14 @@ class RoleUserQuery extends Query { deserialize(List row) { return parseRow(row); } + + RoleQuery get role { + return _role; + } + + UserQuery get user { + return _user; + } } class RoleUserQueryWhere extends QueryWhere { @@ -383,7 +401,7 @@ class RoleQuery extends Query { trampoline ??= Set(); trampoline.add(tableName); _where = RoleQueryWhere(this); - leftJoin(RoleUserQuery(trampoline: trampoline), 'id', 'role_id', + leftJoin(_users = RoleUserQuery(trampoline: trampoline), 'id', 'role_id', additionalFields: const [ 'id', 'created_at', @@ -400,6 +418,8 @@ class RoleQuery extends Query { RoleQueryWhere _where; + RoleUserQuery _users; + @override get casts { return {}; @@ -446,6 +466,10 @@ class RoleQuery extends Query { return parseRow(row); } + RoleUserQuery get users { + return _users; + } + @override bool canCompile(trampoline) { return (!(trampoline.contains('roles') &&