diff --git a/angel_orm_generator/lib/src/orm_generator.dart b/angel_orm_generator/lib/src/orm_generator.dart index 359eb985..1fff92ff 100644 --- a/angel_orm_generator/lib/src/orm_generator.dart +++ b/angel_orm_generator/lib/src/orm_generator.dart @@ -100,7 +100,7 @@ class OrmGenerator extends GeneratorForAnnotation { b ..name = 'postgreSql' ..factory = true - ..redirect = refer('_PostgreSql${rc.pascalCase}OrmImpl') + ..redirect = refer('PostgreSql${rc.pascalCase}Orm') ..requiredParameters.add(new Parameter((b) { b ..name = 'connection' diff --git a/angel_orm_generator/lib/src/postgresql_orm_generator.dart b/angel_orm_generator/lib/src/postgresql_orm_generator.dart index caac4456..99d0af45 100644 --- a/angel_orm_generator/lib/src/postgresql_orm_generator.dart +++ b/angel_orm_generator/lib/src/postgresql_orm_generator.dart @@ -51,7 +51,7 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation { return new Class((clazz) { var rc = ctx.buildContext.modelClassNameRecase; clazz - ..name = '_PostgreSql${rc.pascalCase}OrmImpl' + ..name = 'PostgreSql${rc.pascalCase}Orm' ..implements.add(refer('${rc.pascalCase}Orm')) // final PostgreSQLConnection connection; @@ -74,7 +74,17 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation { ..methods.add(buildDeleteById(ctx)) ..methods.add(buildGetAll(ctx)) ..methods.add(buildCreate(ctx)) - ..methods.add(buildUpdate(ctx)); + ..methods.add(buildUpdate(ctx)) + ..methods.add(buildQuery(ctx)); + }); + } + + Method buildQuery(OrmBuildContext ctx) { + return new Method((m) { + m + ..name = 'query' + ..returns = refer('${ctx.buildContext.modelClassName}Query') + ..body = new Block((b) => b.addExpression(literalNull.returned)); }); } diff --git a/angel_orm_generator/test/models/author.orm.g.dart b/angel_orm_generator/test/models/author.orm.g.dart index 43d3befd..757f8223 100644 --- a/angel_orm_generator/test/models/author.orm.g.dart +++ b/angel_orm_generator/test/models/author.orm.g.dart @@ -11,7 +11,7 @@ part 'author.postgresql.orm.g.dart'; abstract class AuthorOrm { factory AuthorOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlAuthorOrmImpl; + PostgreSqlAuthorOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/author.postgresql.orm.g.dart b/angel_orm_generator/test/models/author.postgresql.orm.g.dart index 767b44f9..f9b04d22 100644 --- a/angel_orm_generator/test/models/author.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/author.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'author.orm.g.dart'; -class _PostgreSqlAuthorOrmImpl implements AuthorOrm { - _PostgreSqlAuthorOrmImpl(this.connection); +class PostgreSqlAuthorOrm implements AuthorOrm { + PostgreSqlAuthorOrm(this.connection); final PostgreSQLConnection connection; @@ -70,4 +70,8 @@ class _PostgreSqlAuthorOrmImpl implements AuthorOrm { }); return parseRow(r.first); } + + AuthorQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/models/car.orm.g.dart b/angel_orm_generator/test/models/car.orm.g.dart index 9595ca52..3a5a96bc 100644 --- a/angel_orm_generator/test/models/car.orm.g.dart +++ b/angel_orm_generator/test/models/car.orm.g.dart @@ -10,8 +10,7 @@ import 'package:postgres/postgres.dart'; part 'car.postgresql.orm.g.dart'; abstract class CarOrm { - factory CarOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlCarOrmImpl; + factory CarOrm.postgreSql(PostgreSQLConnection connection) = PostgreSqlCarOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/car.postgresql.orm.g.dart b/angel_orm_generator/test/models/car.postgresql.orm.g.dart index 68270a27..128f44ae 100644 --- a/angel_orm_generator/test/models/car.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/car.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'car.orm.g.dart'; -class _PostgreSqlCarOrmImpl implements CarOrm { - _PostgreSqlCarOrmImpl(this.connection); +class PostgreSqlCarOrm implements CarOrm { + PostgreSqlCarOrm(this.connection); final PostgreSQLConnection connection; @@ -79,4 +79,8 @@ class _PostgreSqlCarOrmImpl implements CarOrm { }); return parseRow(r.first); } + + CarQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/models/customer.orm.g.dart b/angel_orm_generator/test/models/customer.orm.g.dart index da67eb6e..26136da0 100644 --- a/angel_orm_generator/test/models/customer.orm.g.dart +++ b/angel_orm_generator/test/models/customer.orm.g.dart @@ -11,7 +11,7 @@ part 'customer.postgresql.orm.g.dart'; abstract class CustomerOrm { factory CustomerOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlCustomerOrmImpl; + PostgreSqlCustomerOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/customer.postgresql.orm.g.dart b/angel_orm_generator/test/models/customer.postgresql.orm.g.dart index 61e75a2a..f7174a0c 100644 --- a/angel_orm_generator/test/models/customer.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/customer.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'customer.orm.g.dart'; -class _PostgreSqlCustomerOrmImpl implements CustomerOrm { - _PostgreSqlCustomerOrmImpl(this.connection); +class PostgreSqlCustomerOrm implements CustomerOrm { + PostgreSqlCustomerOrm(this.connection); final PostgreSQLConnection connection; @@ -67,4 +67,8 @@ class _PostgreSqlCustomerOrmImpl implements CustomerOrm { }); return parseRow(r.first); } + + CustomerQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/models/foot.orm.g.dart b/angel_orm_generator/test/models/foot.orm.g.dart index a71aa11c..bd3b456c 100644 --- a/angel_orm_generator/test/models/foot.orm.g.dart +++ b/angel_orm_generator/test/models/foot.orm.g.dart @@ -11,7 +11,7 @@ part 'foot.postgresql.orm.g.dart'; abstract class FootOrm { factory FootOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlFootOrmImpl; + PostgreSqlFootOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/foot.postgresql.orm.g.dart b/angel_orm_generator/test/models/foot.postgresql.orm.g.dart index e495a82c..40579c51 100644 --- a/angel_orm_generator/test/models/foot.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/foot.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'foot.orm.g.dart'; -class _PostgreSqlFootOrmImpl implements FootOrm { - _PostgreSqlFootOrmImpl(this.connection); +class PostgreSqlFootOrm implements FootOrm { + PostgreSqlFootOrm(this.connection); final PostgreSQLConnection connection; @@ -73,4 +73,8 @@ class _PostgreSqlFootOrmImpl implements FootOrm { }); return parseRow(r.first); } + + FootQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/models/fruit.orm.g.dart b/angel_orm_generator/test/models/fruit.orm.g.dart index b48b91d4..6ca4a8d6 100644 --- a/angel_orm_generator/test/models/fruit.orm.g.dart +++ b/angel_orm_generator/test/models/fruit.orm.g.dart @@ -11,7 +11,7 @@ part 'fruit.postgresql.orm.g.dart'; abstract class FruitOrm { factory FruitOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlFruitOrmImpl; + PostgreSqlFruitOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/fruit.postgresql.orm.g.dart b/angel_orm_generator/test/models/fruit.postgresql.orm.g.dart index 275b2c22..fc9b9621 100644 --- a/angel_orm_generator/test/models/fruit.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/fruit.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'fruit.orm.g.dart'; -class _PostgreSqlFruitOrmImpl implements FruitOrm { - _PostgreSqlFruitOrmImpl(this.connection); +class PostgreSqlFruitOrm implements FruitOrm { + PostgreSqlFruitOrm(this.connection); final PostgreSQLConnection connection; @@ -73,4 +73,8 @@ class _PostgreSqlFruitOrmImpl implements FruitOrm { }); return parseRow(r.first); } + + FruitQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/models/order.orm.g.dart b/angel_orm_generator/test/models/order.orm.g.dart index 694cd615..a12fd7a1 100644 --- a/angel_orm_generator/test/models/order.orm.g.dart +++ b/angel_orm_generator/test/models/order.orm.g.dart @@ -11,7 +11,7 @@ part 'order.postgresql.orm.g.dart'; abstract class OrderOrm { factory OrderOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlOrderOrmImpl; + PostgreSqlOrderOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/order.postgresql.orm.g.dart b/angel_orm_generator/test/models/order.postgresql.orm.g.dart index 759ca7c3..dcc8e569 100644 --- a/angel_orm_generator/test/models/order.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/order.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'order.orm.g.dart'; -class _PostgreSqlOrderOrmImpl implements OrderOrm { - _PostgreSqlOrderOrmImpl(this.connection); +class PostgreSqlOrderOrm implements OrderOrm { + PostgreSqlOrderOrm(this.connection); final PostgreSQLConnection connection; @@ -79,4 +79,8 @@ class _PostgreSqlOrderOrmImpl implements OrderOrm { }); return parseRow(r.first); } + + OrderQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/models/role.orm.g.dart b/angel_orm_generator/test/models/role.orm.g.dart index 993e4c60..3040e8d4 100644 --- a/angel_orm_generator/test/models/role.orm.g.dart +++ b/angel_orm_generator/test/models/role.orm.g.dart @@ -11,7 +11,7 @@ part 'role.postgresql.orm.g.dart'; abstract class RoleOrm { factory RoleOrm.postgreSql(PostgreSQLConnection connection) = - _PostgreSqlRoleOrmImpl; + PostgreSqlRoleOrm; Future> getAll(); Future getById(String id); diff --git a/angel_orm_generator/test/models/role.postgresql.orm.g.dart b/angel_orm_generator/test/models/role.postgresql.orm.g.dart index ba7af45c..9fe62351 100644 --- a/angel_orm_generator/test/models/role.postgresql.orm.g.dart +++ b/angel_orm_generator/test/models/role.postgresql.orm.g.dart @@ -6,8 +6,8 @@ part of 'role.orm.g.dart'; -class _PostgreSqlRoleOrmImpl implements RoleOrm { - _PostgreSqlRoleOrmImpl(this.connection); +class PostgreSqlRoleOrm implements RoleOrm { + PostgreSqlRoleOrm(this.connection); final PostgreSQLConnection connection; @@ -70,4 +70,8 @@ class _PostgreSqlRoleOrmImpl implements RoleOrm { }); return parseRow(r.first); } + + RoleQuery query() { + return null; + } } diff --git a/angel_orm_generator/test/standalone_test.dart b/angel_orm_generator/test/standalone_test.dart index 7efa36ef..2ff469ac 100644 --- a/angel_orm_generator/test/standalone_test.dart +++ b/angel_orm_generator/test/standalone_test.dart @@ -33,7 +33,7 @@ main() { dateYmdHms.format(MILENNIUM) ]; print(row); - var car = CarQuery.parseRow(row); + var car = PostgreSqlCarOrm.parseRow(row); print(car.toJson()); expect(car.id, '0'); expect(car.make, 'Mazda');