un-private
This commit is contained in:
parent
4b374597eb
commit
6f33f28402
17 changed files with 63 additions and 26 deletions
|
@ -100,7 +100,7 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
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'
|
||||
|
|
|
@ -51,7 +51,7 @@ class PostgreSqlOrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
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<Orm> {
|
|||
..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));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@ part 'author.postgresql.orm.g.dart';
|
|||
|
||||
abstract class AuthorOrm {
|
||||
factory AuthorOrm.postgreSql(PostgreSQLConnection connection) =
|
||||
_PostgreSqlAuthorOrmImpl;
|
||||
PostgreSqlAuthorOrm;
|
||||
|
||||
Future<List<Author>> getAll();
|
||||
Future<Author> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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<List<Car>> getAll();
|
||||
Future<Car> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ part 'customer.postgresql.orm.g.dart';
|
|||
|
||||
abstract class CustomerOrm {
|
||||
factory CustomerOrm.postgreSql(PostgreSQLConnection connection) =
|
||||
_PostgreSqlCustomerOrmImpl;
|
||||
PostgreSqlCustomerOrm;
|
||||
|
||||
Future<List<Customer>> getAll();
|
||||
Future<Customer> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ part 'foot.postgresql.orm.g.dart';
|
|||
|
||||
abstract class FootOrm {
|
||||
factory FootOrm.postgreSql(PostgreSQLConnection connection) =
|
||||
_PostgreSqlFootOrmImpl;
|
||||
PostgreSqlFootOrm;
|
||||
|
||||
Future<List<Foot>> getAll();
|
||||
Future<Foot> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ part 'fruit.postgresql.orm.g.dart';
|
|||
|
||||
abstract class FruitOrm {
|
||||
factory FruitOrm.postgreSql(PostgreSQLConnection connection) =
|
||||
_PostgreSqlFruitOrmImpl;
|
||||
PostgreSqlFruitOrm;
|
||||
|
||||
Future<List<Fruit>> getAll();
|
||||
Future<Fruit> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ part 'order.postgresql.orm.g.dart';
|
|||
|
||||
abstract class OrderOrm {
|
||||
factory OrderOrm.postgreSql(PostgreSQLConnection connection) =
|
||||
_PostgreSqlOrderOrmImpl;
|
||||
PostgreSqlOrderOrm;
|
||||
|
||||
Future<List<Order>> getAll();
|
||||
Future<Order> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ part 'role.postgresql.orm.g.dart';
|
|||
|
||||
abstract class RoleOrm {
|
||||
factory RoleOrm.postgreSql(PostgreSQLConnection connection) =
|
||||
_PostgreSqlRoleOrmImpl;
|
||||
PostgreSqlRoleOrm;
|
||||
|
||||
Future<List<Role>> getAll();
|
||||
Future<Role> getById(String id);
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in a new issue