2.0.0-dev.2
This commit is contained in:
parent
047dc76408
commit
b62f26a0af
20 changed files with 472 additions and 319 deletions
|
@ -451,7 +451,11 @@ class Union<T> extends QueryBase<T> {
|
|||
final QueryBase<T> left, right;
|
||||
final bool all;
|
||||
|
||||
Union(this.left, this.right, {this.all: false});
|
||||
Union(this.left, this.right, {this.all: false}) {
|
||||
substitutionValues
|
||||
..addAll(left.substitutionValues)
|
||||
..addAll(right.substitutionValues);
|
||||
}
|
||||
|
||||
@override
|
||||
List<String> get fields => left.fields;
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
# 2.0.0-dev.2
|
||||
* Changes to work with `package:angel_orm@2.0.0-dev.15`.
|
||||
|
||||
# 2.0.0-dev.1
|
||||
* Generate migration files.
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:angel_orm/angel_orm.dart';
|
||||
import 'package:angel_serialize_generator/angel_serialize_generator.dart';
|
||||
import 'package:build/build.dart';
|
||||
import 'package:code_builder/code_builder.dart';
|
||||
import 'package:dart_style/dart_style.dart';
|
||||
|
@ -168,9 +169,14 @@ class MigrationGenerator extends GeneratorForAnnotation<Orm> {
|
|||
var field = table.property(methodName).call(positional, named);
|
||||
var cascade = <Expression>[];
|
||||
|
||||
if (col.defaultValue != null) {
|
||||
cascade
|
||||
.add(refer('defaultsTo').call([literal(col.defaultValue)]));
|
||||
var defaultValue = ctx.buildContext.defaults[name];
|
||||
|
||||
if (defaultValue != null) {
|
||||
cascade.add(refer('defaultsTo').call([
|
||||
new CodeExpression(
|
||||
new Code(dartObjectToString(defaultValue)),
|
||||
),
|
||||
]));
|
||||
}
|
||||
|
||||
if (col.indexType == IndexType.primaryKey ||
|
||||
|
|
|
@ -86,7 +86,6 @@ Future<OrmBuildContext> buildOrmContext(
|
|||
isNullable: column.isNullable,
|
||||
length: column.length,
|
||||
indexType: column.indexType,
|
||||
defaultValue: column.defaultValue,
|
||||
type: inferColumnType(field.type),
|
||||
);
|
||||
}
|
||||
|
@ -233,7 +232,6 @@ Column reviveColumn(ConstantReader cr) {
|
|||
return new Column(
|
||||
isNullable: cr.peek('isNullable')?.boolValue,
|
||||
length: cr.peek('length')?.intValue,
|
||||
defaultValue: cr.peek('defaultValue')?.literalValue,
|
||||
type: columnType,
|
||||
indexType: indexType,
|
||||
);
|
||||
|
|
|
@ -105,23 +105,30 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
});
|
||||
}));
|
||||
|
||||
// Add where member
|
||||
// Add _where member
|
||||
clazz.fields.add(new Field((b) {
|
||||
b
|
||||
..annotations.add(refer('override'))
|
||||
..name = 'where'
|
||||
..modifier = FieldModifier.final$
|
||||
..type = queryWhereType
|
||||
..assignment = queryWhereType.newInstance([]).code;
|
||||
..name = '_where'
|
||||
..type = queryWhereType;
|
||||
}));
|
||||
|
||||
// Add where getter
|
||||
clazz.methods.add(new Method((b) {
|
||||
b
|
||||
..name = 'where'
|
||||
..type = MethodType.getter
|
||||
..returns = queryWhereType
|
||||
..annotations.add(refer('override'))
|
||||
..body = new Block((b) => b.addExpression(refer('_where').returned));
|
||||
}));
|
||||
// newWhereClause()
|
||||
clazz.methods.add(new Method((b) {
|
||||
b
|
||||
..name = 'newWhereClause'
|
||||
..annotations.add(refer('override'))
|
||||
..returns = queryWhereType
|
||||
..body = new Block(
|
||||
(b) => b.addExpression(queryWhereType.newInstance([]).returned));
|
||||
..body = new Block((b) => b.addExpression(
|
||||
queryWhereType.newInstance([refer('this')]).returned));
|
||||
}));
|
||||
|
||||
// Add deserialize()
|
||||
|
@ -197,88 +204,91 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
}));
|
||||
|
||||
// If there are any relations, we need some overrides.
|
||||
clazz.constructors.add(new Constructor((b) {
|
||||
b
|
||||
..body = new Block((b) {
|
||||
// Add a constructor that initializes _where
|
||||
b.addExpression(
|
||||
refer('_where')
|
||||
.assign(queryWhereType.newInstance([refer('this')])),
|
||||
);
|
||||
|
||||
ctx.relations.forEach((fieldName, relation) {
|
||||
//var name = ctx.buildContext.resolveFieldName(fieldName);
|
||||
if (relation.type == RelationshipType.belongsTo ||
|
||||
relation.type == RelationshipType.hasOne) {
|
||||
var foreign = ctx.relationTypes[relation];
|
||||
var additionalFields = foreign.effectiveFields
|
||||
.where((f) => f.name != 'id' || !isSpecialId(f))
|
||||
.map((f) => literalString(
|
||||
foreign.buildContext.resolveFieldName(f.name)));
|
||||
var joinArgs = [
|
||||
relation.foreignTable,
|
||||
relation.localKey,
|
||||
relation.foreignKey
|
||||
].map(literalString);
|
||||
b.addExpression(refer('leftJoin').call(joinArgs, {
|
||||
'additionalFields':
|
||||
literalConstList(additionalFields.toList())
|
||||
}));
|
||||
}
|
||||
});
|
||||
});
|
||||
}));
|
||||
if (ctx.relations.isNotEmpty) {
|
||||
clazz.constructors.add(new Constructor((b) {
|
||||
clazz.methods.add(new Method((b) {
|
||||
b
|
||||
..name = 'insert'
|
||||
..annotations.add(refer('override'))
|
||||
..requiredParameters.add(new Parameter((b) => b..name = 'executor'))
|
||||
..body = new Block((b) {
|
||||
ctx.relations.forEach((fieldName, relation) {
|
||||
//var name = ctx.buildContext.resolveFieldName(fieldName);
|
||||
if (relation.type == RelationshipType.belongsTo ||
|
||||
relation.type == RelationshipType.hasOne) {
|
||||
var foreign = ctx.relationTypes[relation];
|
||||
var additionalFields = foreign.effectiveFields
|
||||
.where((f) => f.name != 'id' || !isSpecialId(f))
|
||||
.map((f) => literalString(
|
||||
foreign.buildContext.resolveFieldName(f.name)));
|
||||
var joinArgs = [
|
||||
relation.foreignTable,
|
||||
relation.localKey,
|
||||
relation.foreignKey
|
||||
].map(literalString);
|
||||
b.addExpression(refer('leftJoin').call(joinArgs, {
|
||||
'additionalFields':
|
||||
literalConstList(additionalFields.toList())
|
||||
}));
|
||||
}
|
||||
var inTransaction = new Method((b) {
|
||||
b
|
||||
..modifier = MethodModifier.async
|
||||
..body = new Block((b) {
|
||||
b.addExpression(refer('super')
|
||||
.property('insert')
|
||||
.call([refer('executor')])
|
||||
.awaited
|
||||
.assignVar('result'));
|
||||
|
||||
// Just call getOne() again
|
||||
if (ctx.effectiveFields.any((f) =>
|
||||
isSpecialId(f) ||
|
||||
(ctx.columns[f.name]?.indexType ==
|
||||
IndexType.primaryKey))) {
|
||||
b.addExpression(refer('where')
|
||||
.property('id')
|
||||
.property('equals')
|
||||
.call([
|
||||
(refer('int')
|
||||
.property('parse')
|
||||
.call([refer('result').property('id')]))
|
||||
]));
|
||||
|
||||
b.addExpression(refer('result').assign(
|
||||
refer('getOne').call([refer('executor')]).awaited));
|
||||
}
|
||||
|
||||
// Fetch the results of @hasMany
|
||||
ctx.relations.forEach((name, relation) {
|
||||
if (relation.type == RelationshipType.hasMany) {
|
||||
// Call fetchLinked();
|
||||
var fetchLinked = refer('fetchLinked')
|
||||
.call([refer('result'), refer('executor')]).awaited;
|
||||
b.addExpression(refer('result').assign(fetchLinked));
|
||||
}
|
||||
});
|
||||
|
||||
b.addExpression(refer('result').returned);
|
||||
});
|
||||
});
|
||||
|
||||
b.addExpression(refer('executor')
|
||||
.property('transaction')
|
||||
.call([inTransaction.closure]).returned);
|
||||
});
|
||||
}));
|
||||
if (ctx.relations.isNotEmpty) {
|
||||
clazz.methods.add(new Method((b) {
|
||||
b
|
||||
..name = 'insert'
|
||||
..annotations.add(refer('override'))
|
||||
..requiredParameters
|
||||
.add(new Parameter((b) => b..name = 'executor'))
|
||||
..body = new Block((b) {
|
||||
var inTransaction = new Method((b) {
|
||||
b
|
||||
..modifier = MethodModifier.async
|
||||
..body = new Block((b) {
|
||||
b.addExpression(refer('super')
|
||||
.property('insert')
|
||||
.call([refer('executor')])
|
||||
.awaited
|
||||
.assignVar('result'));
|
||||
|
||||
// Just call getOne() again
|
||||
if (ctx.effectiveFields.any((f) =>
|
||||
isSpecialId(f) ||
|
||||
(ctx.columns[f.name]?.indexType ==
|
||||
IndexType.primaryKey))) {
|
||||
b.addExpression(refer('where')
|
||||
.property('id')
|
||||
.property('equals')
|
||||
.call([
|
||||
(refer('int')
|
||||
.property('parse')
|
||||
.call([refer('result').property('id')]))
|
||||
]));
|
||||
|
||||
b.addExpression(refer('result').assign(
|
||||
refer('getOne').call([refer('executor')]).awaited));
|
||||
}
|
||||
|
||||
// Fetch the results of @hasMany
|
||||
ctx.relations.forEach((name, relation) {
|
||||
if (relation.type == RelationshipType.hasMany) {
|
||||
// Call fetchLinked();
|
||||
var fetchLinked = refer('fetchLinked').call(
|
||||
[refer('result'), refer('executor')]).awaited;
|
||||
b.addExpression(refer('result').assign(fetchLinked));
|
||||
}
|
||||
});
|
||||
|
||||
b.addExpression(refer('result').returned);
|
||||
});
|
||||
});
|
||||
|
||||
b.addExpression(refer('executor')
|
||||
.property('transaction')
|
||||
.call([inTransaction.closure]).returned);
|
||||
});
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
// Create a Future<T> fetchLinked(T model, QueryExecutor), if necessary.
|
||||
|
@ -412,6 +422,8 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
});
|
||||
}));
|
||||
|
||||
var initializers = <Code>[];
|
||||
|
||||
// Add builders for each field
|
||||
for (var field in ctx.effectiveFields) {
|
||||
var name = field.name;
|
||||
|
@ -451,12 +463,27 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
b
|
||||
..name = name
|
||||
..modifier = FieldModifier.final$
|
||||
..type = builderType
|
||||
..assignment = builderType.newInstance([
|
||||
literalString(ctx.buildContext.resolveFieldName(field.name))
|
||||
]).code;
|
||||
..type = builderType;
|
||||
|
||||
initializers.add(
|
||||
refer(field.name)
|
||||
.assign(builderType.newInstance([
|
||||
refer('query'),
|
||||
literalString(ctx.buildContext.resolveFieldName(field.name))
|
||||
]))
|
||||
.code,
|
||||
);
|
||||
}));
|
||||
}
|
||||
|
||||
// Now, just add a constructor that initializes each builder.
|
||||
clazz.constructors.add(new Constructor((b) {
|
||||
b
|
||||
..requiredParameters.add(new Parameter((b) => b
|
||||
..name = 'query'
|
||||
..type = refer('${rc.pascalCase}Query')))
|
||||
..initializers.addAll(initializers);
|
||||
}));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -487,7 +514,6 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
b
|
||||
..name = field.name
|
||||
..type = MethodType.setter
|
||||
..returns = refer('void')
|
||||
..requiredParameters.add(new Parameter((b) => b
|
||||
..name = 'value'
|
||||
..type = type))
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel_orm_generator
|
||||
version: 2.0.0-dev.1
|
||||
version: 2.0.0-dev.2
|
||||
description: Code generators for Angel's ORM. Generates query builder classes.
|
||||
author: Tobe O <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/orm
|
||||
|
@ -34,3 +34,6 @@ dev_dependencies:
|
|||
collection: ^1.0.0
|
||||
postgres: ^1.0.0
|
||||
test: ^1.0.0
|
||||
# dependency_overrides:
|
||||
# angel_orm:
|
||||
# path: ../angel_orm
|
||||
|
|
|
@ -88,7 +88,7 @@ main() {
|
|||
});
|
||||
|
||||
test('union', () async {
|
||||
var query1 = new BookQuery()..where.name.like('Deathly%');
|
||||
var query1 = new BookQuery()..where.name.like((_) => 'Deathly%');
|
||||
var query2 = new BookQuery()..where.authorId.equals(-1);
|
||||
var query3 = new BookQuery()
|
||||
..where.name.isIn(['Goblet of Fire', 'Order of the Phoenix']);
|
||||
|
|
|
@ -23,15 +23,20 @@ class PostgresExecutor extends QueryExecutor {
|
|||
Future close() => (connection as PostgreSQLConnection).close();
|
||||
|
||||
@override
|
||||
Future<List<List>> query(String query, [List<String> returningFields]) {
|
||||
Future<List<List>> query(
|
||||
String query, Map<String, dynamic> substitutionValues,
|
||||
[List<String> returningFields]) {
|
||||
if (returningFields != null) {
|
||||
var fields = returningFields.join(', ');
|
||||
var returning = 'RETURNING $fields';
|
||||
query = '$query $returning';
|
||||
}
|
||||
|
||||
if (!Platform.environment.containsKey('STFU')) print('Running: $query');
|
||||
return connection.query(query);
|
||||
if (!Platform.environment.containsKey('STFU')) {
|
||||
print('Running: $query');
|
||||
if (substitutionValues.isNotEmpty) print('Values: $substitutionValues');
|
||||
}
|
||||
return connection.query(query, substitutionValues: substitutionValues);
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -9,6 +9,7 @@ part 'author.g.dart';
|
|||
@serializable
|
||||
@orm
|
||||
abstract class _Author extends Model {
|
||||
@Column(length: 255, indexType: IndexType.unique, defaultValue: 'Tobe Osakwe')
|
||||
@Column(length: 255, indexType: IndexType.unique)
|
||||
@DefaultValue('Tobe Osakwe')
|
||||
String get name;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ class AuthorMigration extends Migration {
|
|||
up(Schema schema) {
|
||||
schema.create('authors', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.varChar('name');
|
||||
table.varChar('name')..defaultsTo('Tobe Osakwe');
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
});
|
||||
|
@ -28,11 +28,14 @@ class AuthorMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class AuthorQuery extends Query<Author, AuthorQueryWhere> {
|
||||
AuthorQuery() {
|
||||
_where = new AuthorQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final AuthorQueryValues values = new AuthorQueryValues();
|
||||
|
||||
@override
|
||||
final AuthorQueryWhere where = new AuthorQueryWhere();
|
||||
AuthorQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -44,9 +47,14 @@ class AuthorQuery extends Query<Author, AuthorQueryWhere> {
|
|||
return const ['id', 'name', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
AuthorQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
AuthorQueryWhere newWhereClause() {
|
||||
return new AuthorQueryWhere();
|
||||
return new AuthorQueryWhere(this);
|
||||
}
|
||||
|
||||
static Author parseRow(List row) {
|
||||
|
@ -66,17 +74,19 @@ class AuthorQuery extends Query<Author, AuthorQueryWhere> {
|
|||
}
|
||||
|
||||
class AuthorQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
AuthorQueryWhere(AuthorQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
name = new StringSqlExpressionBuilder(query, 'name'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final StringSqlExpressionBuilder name =
|
||||
new StringSqlExpressionBuilder('name');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final StringSqlExpressionBuilder name;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -89,22 +99,22 @@ class AuthorQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
String get name {
|
||||
return (values['name'] as String);
|
||||
}
|
||||
|
||||
void set name(String value) => values['name'] = value;
|
||||
set name(String value) => values['name'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Author model) {
|
||||
values.addAll({
|
||||
'name': model.name,
|
||||
|
@ -120,7 +130,7 @@ class AuthorQueryValues extends MapQueryValues {
|
|||
|
||||
@generatedSerializable
|
||||
class Author extends _Author {
|
||||
Author({this.id, this.name, this.createdAt, this.updatedAt});
|
||||
Author({this.id, this.name: 'Tobe Osakwe', this.createdAt, this.updatedAt});
|
||||
|
||||
@override
|
||||
final String id;
|
||||
|
@ -169,7 +179,7 @@ abstract class AuthorSerializer {
|
|||
static Author fromMap(Map map) {
|
||||
return new Author(
|
||||
id: map['id'] as String,
|
||||
name: map['name'] as String,
|
||||
name: map['name'] as String ?? 'Tobe Osakwe',
|
||||
createdAt: map['created_at'] != null
|
||||
? (map['created_at'] is DateTime
|
||||
? (map['created_at'] as DateTime)
|
||||
|
|
|
@ -31,6 +31,7 @@ class BookMigration extends Migration {
|
|||
|
||||
class BookQuery extends Query<Book, BookQueryWhere> {
|
||||
BookQuery() {
|
||||
_where = new BookQueryWhere(this);
|
||||
leftJoin('authors', 'author_id', 'id',
|
||||
additionalFields: const ['name', 'created_at', 'updated_at']);
|
||||
leftJoin('authors', 'partner_author_id', 'id',
|
||||
|
@ -40,8 +41,7 @@ class BookQuery extends Query<Book, BookQueryWhere> {
|
|||
@override
|
||||
final BookQueryValues values = new BookQueryValues();
|
||||
|
||||
@override
|
||||
final BookQueryWhere where = new BookQueryWhere();
|
||||
BookQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -60,9 +60,14 @@ class BookQuery extends Query<Book, BookQueryWhere> {
|
|||
];
|
||||
}
|
||||
|
||||
@override
|
||||
BookQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
BookQueryWhere newWhereClause() {
|
||||
return new BookQueryWhere();
|
||||
return new BookQueryWhere(this);
|
||||
}
|
||||
|
||||
static Book parseRow(List row) {
|
||||
|
@ -100,23 +105,26 @@ class BookQuery extends Query<Book, BookQueryWhere> {
|
|||
}
|
||||
|
||||
class BookQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
BookQueryWhere(BookQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
authorId = new NumericSqlExpressionBuilder<int>(query, 'author_id'),
|
||||
partnerAuthorId =
|
||||
new NumericSqlExpressionBuilder<int>(query, 'partner_author_id'),
|
||||
name = new StringSqlExpressionBuilder(query, 'name'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> authorId =
|
||||
new NumericSqlExpressionBuilder<int>('author_id');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final NumericSqlExpressionBuilder<int> partnerAuthorId =
|
||||
new NumericSqlExpressionBuilder<int>('partner_author_id');
|
||||
final NumericSqlExpressionBuilder<int> authorId;
|
||||
|
||||
final StringSqlExpressionBuilder name =
|
||||
new StringSqlExpressionBuilder('name');
|
||||
final NumericSqlExpressionBuilder<int> partnerAuthorId;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final StringSqlExpressionBuilder name;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -129,32 +137,32 @@ class BookQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
int get authorId {
|
||||
return (values['author_id'] as int);
|
||||
}
|
||||
|
||||
void set authorId(int value) => values['author_id'] = value;
|
||||
set authorId(int value) => values['author_id'] = value;
|
||||
int get partnerAuthorId {
|
||||
return (values['partner_author_id'] as int);
|
||||
}
|
||||
|
||||
void set partnerAuthorId(int value) => values['partner_author_id'] = value;
|
||||
set partnerAuthorId(int value) => values['partner_author_id'] = value;
|
||||
String get name {
|
||||
return (values['name'] as String);
|
||||
}
|
||||
|
||||
void set name(String value) => values['name'] = value;
|
||||
set name(String value) => values['name'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Book model) {
|
||||
values.addAll({
|
||||
'name': model.name,
|
||||
|
|
|
@ -31,11 +31,14 @@ class CarMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class CarQuery extends Query<Car, CarQueryWhere> {
|
||||
CarQuery() {
|
||||
_where = new CarQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final CarQueryValues values = new CarQueryValues();
|
||||
|
||||
@override
|
||||
final CarQueryWhere where = new CarQueryWhere();
|
||||
CarQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -55,9 +58,14 @@ class CarQuery extends Query<Car, CarQueryWhere> {
|
|||
];
|
||||
}
|
||||
|
||||
@override
|
||||
CarQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
CarQueryWhere newWhereClause() {
|
||||
return new CarQueryWhere();
|
||||
return new CarQueryWhere(this);
|
||||
}
|
||||
|
||||
static Car parseRow(List row) {
|
||||
|
@ -80,26 +88,29 @@ class CarQuery extends Query<Car, CarQueryWhere> {
|
|||
}
|
||||
|
||||
class CarQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
CarQueryWhere(CarQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
make = new StringSqlExpressionBuilder(query, 'make'),
|
||||
description = new StringSqlExpressionBuilder(query, 'description'),
|
||||
familyFriendly =
|
||||
new BooleanSqlExpressionBuilder(query, 'family_friendly'),
|
||||
recalledAt = new DateTimeSqlExpressionBuilder(query, 'recalled_at'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final StringSqlExpressionBuilder make =
|
||||
new StringSqlExpressionBuilder('make');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final StringSqlExpressionBuilder description =
|
||||
new StringSqlExpressionBuilder('description');
|
||||
final StringSqlExpressionBuilder make;
|
||||
|
||||
final BooleanSqlExpressionBuilder familyFriendly =
|
||||
new BooleanSqlExpressionBuilder('family_friendly');
|
||||
final StringSqlExpressionBuilder description;
|
||||
|
||||
final DateTimeSqlExpressionBuilder recalledAt =
|
||||
new DateTimeSqlExpressionBuilder('recalled_at');
|
||||
final BooleanSqlExpressionBuilder familyFriendly;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final DateTimeSqlExpressionBuilder recalledAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -120,37 +131,37 @@ class CarQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
String get make {
|
||||
return (values['make'] as String);
|
||||
}
|
||||
|
||||
void set make(String value) => values['make'] = value;
|
||||
set make(String value) => values['make'] = value;
|
||||
String get description {
|
||||
return (values['description'] as String);
|
||||
}
|
||||
|
||||
void set description(String value) => values['description'] = value;
|
||||
set description(String value) => values['description'] = value;
|
||||
bool get familyFriendly {
|
||||
return (values['family_friendly'] as bool);
|
||||
}
|
||||
|
||||
void set familyFriendly(bool value) => values['family_friendly'] = value;
|
||||
set familyFriendly(bool value) => values['family_friendly'] = value;
|
||||
DateTime get recalledAt {
|
||||
return (values['recalled_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set recalledAt(DateTime value) => values['recalled_at'] = value;
|
||||
set recalledAt(DateTime value) => values['recalled_at'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Car model) {
|
||||
values.addAll({
|
||||
'make': model.make,
|
||||
|
|
|
@ -27,11 +27,14 @@ class CustomerMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
|
||||
CustomerQuery() {
|
||||
_where = new CustomerQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final CustomerQueryValues values = new CustomerQueryValues();
|
||||
|
||||
@override
|
||||
final CustomerQueryWhere where = new CustomerQueryWhere();
|
||||
CustomerQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -43,9 +46,14 @@ class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
|
|||
return const ['id', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
CustomerQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
CustomerQueryWhere newWhereClause() {
|
||||
return new CustomerQueryWhere();
|
||||
return new CustomerQueryWhere(this);
|
||||
}
|
||||
|
||||
static Customer parseRow(List row) {
|
||||
|
@ -64,14 +72,16 @@ class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
|
|||
}
|
||||
|
||||
class CustomerQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
CustomerQueryWhere(CustomerQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -84,17 +94,17 @@ class CustomerQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Customer model) {
|
||||
values
|
||||
.addAll({'created_at': model.createdAt, 'updated_at': model.updatedAt});
|
||||
|
|
|
@ -29,11 +29,14 @@ class FootMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class FootQuery extends Query<Foot, FootQueryWhere> {
|
||||
FootQuery() {
|
||||
_where = new FootQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final FootQueryValues values = new FootQueryValues();
|
||||
|
||||
@override
|
||||
final FootQueryWhere where = new FootQueryWhere();
|
||||
FootQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -45,9 +48,14 @@ class FootQuery extends Query<Foot, FootQueryWhere> {
|
|||
return const ['id', 'leg_id', 'n_toes', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
FootQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
FootQueryWhere newWhereClause() {
|
||||
return new FootQueryWhere();
|
||||
return new FootQueryWhere(this);
|
||||
}
|
||||
|
||||
static Foot parseRow(List row) {
|
||||
|
@ -68,20 +76,22 @@ class FootQuery extends Query<Foot, FootQueryWhere> {
|
|||
}
|
||||
|
||||
class FootQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
FootQueryWhere(FootQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
legId = new NumericSqlExpressionBuilder<int>(query, 'leg_id'),
|
||||
nToes = new NumericSqlExpressionBuilder<int>(query, 'n_toes'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> legId =
|
||||
new NumericSqlExpressionBuilder<int>('leg_id');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final NumericSqlExpressionBuilder<int> nToes =
|
||||
new NumericSqlExpressionBuilder<int>('n_toes');
|
||||
final NumericSqlExpressionBuilder<int> legId;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final NumericSqlExpressionBuilder<int> nToes;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -94,27 +104,27 @@ class FootQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
int get legId {
|
||||
return (values['leg_id'] as int);
|
||||
}
|
||||
|
||||
void set legId(int value) => values['leg_id'] = value;
|
||||
set legId(int value) => values['leg_id'] = value;
|
||||
int get nToes {
|
||||
return (values['n_toes'] as int);
|
||||
}
|
||||
|
||||
void set nToes(int value) => values['n_toes'] = value;
|
||||
set nToes(int value) => values['n_toes'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Foot model) {
|
||||
values.addAll({
|
||||
'leg_id': model.legId,
|
||||
|
|
|
@ -29,11 +29,14 @@ class FruitMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class FruitQuery extends Query<Fruit, FruitQueryWhere> {
|
||||
FruitQuery() {
|
||||
_where = new FruitQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final FruitQueryValues values = new FruitQueryValues();
|
||||
|
||||
@override
|
||||
final FruitQueryWhere where = new FruitQueryWhere();
|
||||
FruitQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -45,9 +48,14 @@ class FruitQuery extends Query<Fruit, FruitQueryWhere> {
|
|||
return const ['id', 'tree_id', 'common_name', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
FruitQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
FruitQueryWhere newWhereClause() {
|
||||
return new FruitQueryWhere();
|
||||
return new FruitQueryWhere(this);
|
||||
}
|
||||
|
||||
static Fruit parseRow(List row) {
|
||||
|
@ -68,20 +76,22 @@ class FruitQuery extends Query<Fruit, FruitQueryWhere> {
|
|||
}
|
||||
|
||||
class FruitQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
FruitQueryWhere(FruitQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
treeId = new NumericSqlExpressionBuilder<int>(query, 'tree_id'),
|
||||
commonName = new StringSqlExpressionBuilder(query, 'common_name'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> treeId =
|
||||
new NumericSqlExpressionBuilder<int>('tree_id');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final StringSqlExpressionBuilder commonName =
|
||||
new StringSqlExpressionBuilder('common_name');
|
||||
final NumericSqlExpressionBuilder<int> treeId;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final StringSqlExpressionBuilder commonName;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -94,27 +104,27 @@ class FruitQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
int get treeId {
|
||||
return (values['tree_id'] as int);
|
||||
}
|
||||
|
||||
void set treeId(int value) => values['tree_id'] = value;
|
||||
set treeId(int value) => values['tree_id'] = value;
|
||||
String get commonName {
|
||||
return (values['common_name'] as String);
|
||||
}
|
||||
|
||||
void set commonName(String value) => values['common_name'] = value;
|
||||
set commonName(String value) => values['common_name'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Fruit model) {
|
||||
values.addAll({
|
||||
'tree_id': model.treeId,
|
||||
|
|
|
@ -29,6 +29,7 @@ class LegMigration extends Migration {
|
|||
|
||||
class LegQuery extends Query<Leg, LegQueryWhere> {
|
||||
LegQuery() {
|
||||
_where = new LegQueryWhere(this);
|
||||
leftJoin('feet', 'id', 'leg_id', additionalFields: const [
|
||||
'leg_id',
|
||||
'n_toes',
|
||||
|
@ -40,8 +41,7 @@ class LegQuery extends Query<Leg, LegQueryWhere> {
|
|||
@override
|
||||
final LegQueryValues values = new LegQueryValues();
|
||||
|
||||
@override
|
||||
final LegQueryWhere where = new LegQueryWhere();
|
||||
LegQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -53,9 +53,14 @@ class LegQuery extends Query<Leg, LegQueryWhere> {
|
|||
return const ['id', 'name', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
LegQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
LegQueryWhere newWhereClause() {
|
||||
return new LegQueryWhere();
|
||||
return new LegQueryWhere(this);
|
||||
}
|
||||
|
||||
static Leg parseRow(List row) {
|
||||
|
@ -88,17 +93,19 @@ class LegQuery extends Query<Leg, LegQueryWhere> {
|
|||
}
|
||||
|
||||
class LegQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
LegQueryWhere(LegQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
name = new StringSqlExpressionBuilder(query, 'name'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final StringSqlExpressionBuilder name =
|
||||
new StringSqlExpressionBuilder('name');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final StringSqlExpressionBuilder name;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -111,22 +118,22 @@ class LegQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
String get name {
|
||||
return (values['name'] as String);
|
||||
}
|
||||
|
||||
void set name(String value) => values['name'] = value;
|
||||
set name(String value) => values['name'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Leg model) {
|
||||
values.addAll({
|
||||
'name': model.name,
|
||||
|
|
|
@ -31,11 +31,14 @@ class OrderMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class OrderQuery extends Query<Order, OrderQueryWhere> {
|
||||
OrderQuery() {
|
||||
_where = new OrderQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final OrderQueryValues values = new OrderQueryValues();
|
||||
|
||||
@override
|
||||
final OrderQueryWhere where = new OrderQueryWhere();
|
||||
OrderQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -55,9 +58,14 @@ class OrderQuery extends Query<Order, OrderQueryWhere> {
|
|||
];
|
||||
}
|
||||
|
||||
@override
|
||||
OrderQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
OrderQueryWhere newWhereClause() {
|
||||
return new OrderQueryWhere();
|
||||
return new OrderQueryWhere(this);
|
||||
}
|
||||
|
||||
static Order parseRow(List row) {
|
||||
|
@ -80,26 +88,28 @@ class OrderQuery extends Query<Order, OrderQueryWhere> {
|
|||
}
|
||||
|
||||
class OrderQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
OrderQueryWhere(OrderQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
customerId = new NumericSqlExpressionBuilder<int>(query, 'customer_id'),
|
||||
employeeId = new NumericSqlExpressionBuilder<int>(query, 'employee_id'),
|
||||
orderDate = new DateTimeSqlExpressionBuilder(query, 'order_date'),
|
||||
shipperId = new NumericSqlExpressionBuilder<int>(query, 'shipper_id'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> customerId =
|
||||
new NumericSqlExpressionBuilder<int>('customer_id');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final NumericSqlExpressionBuilder<int> employeeId =
|
||||
new NumericSqlExpressionBuilder<int>('employee_id');
|
||||
final NumericSqlExpressionBuilder<int> customerId;
|
||||
|
||||
final DateTimeSqlExpressionBuilder orderDate =
|
||||
new DateTimeSqlExpressionBuilder('order_date');
|
||||
final NumericSqlExpressionBuilder<int> employeeId;
|
||||
|
||||
final NumericSqlExpressionBuilder<int> shipperId =
|
||||
new NumericSqlExpressionBuilder<int>('shipper_id');
|
||||
final DateTimeSqlExpressionBuilder orderDate;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final NumericSqlExpressionBuilder<int> shipperId;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -120,37 +130,37 @@ class OrderQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
int get customerId {
|
||||
return (values['customer_id'] as int);
|
||||
}
|
||||
|
||||
void set customerId(int value) => values['customer_id'] = value;
|
||||
set customerId(int value) => values['customer_id'] = value;
|
||||
int get employeeId {
|
||||
return (values['employee_id'] as int);
|
||||
}
|
||||
|
||||
void set employeeId(int value) => values['employee_id'] = value;
|
||||
set employeeId(int value) => values['employee_id'] = value;
|
||||
DateTime get orderDate {
|
||||
return (values['order_date'] as DateTime);
|
||||
}
|
||||
|
||||
void set orderDate(DateTime value) => values['order_date'] = value;
|
||||
set orderDate(DateTime value) => values['order_date'] = value;
|
||||
int get shipperId {
|
||||
return (values['shipper_id'] as int);
|
||||
}
|
||||
|
||||
void set shipperId(int value) => values['shipper_id'] = value;
|
||||
set shipperId(int value) => values['shipper_id'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Order model) {
|
||||
values.addAll({
|
||||
'customer_id': model.customerId,
|
||||
|
|
|
@ -28,13 +28,14 @@ class TreeMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
||||
TreeQuery() {}
|
||||
TreeQuery() {
|
||||
_where = new TreeQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final TreeQueryValues values = new TreeQueryValues();
|
||||
|
||||
@override
|
||||
final TreeQueryWhere where = new TreeQueryWhere();
|
||||
TreeQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -46,9 +47,14 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|||
return const ['id', 'rings', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
TreeQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
TreeQueryWhere newWhereClause() {
|
||||
return new TreeQueryWhere();
|
||||
return new TreeQueryWhere(this);
|
||||
}
|
||||
|
||||
static Tree parseRow(List row) {
|
||||
|
@ -110,17 +116,19 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|||
}
|
||||
|
||||
class TreeQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
TreeQueryWhere(TreeQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
rings = new NumericSqlExpressionBuilder<int>(query, 'rings'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> rings =
|
||||
new NumericSqlExpressionBuilder<int>('rings');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final NumericSqlExpressionBuilder<int> rings;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -133,22 +141,22 @@ class TreeQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
int get rings {
|
||||
return (values['rings'] as int);
|
||||
}
|
||||
|
||||
void set rings(int value) => values['rings'] = value;
|
||||
set rings(int value) => values['rings'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Tree model) {
|
||||
values.addAll({
|
||||
'rings': model.rings,
|
||||
|
|
|
@ -63,13 +63,14 @@ class UserRoleMigration extends Migration {
|
|||
// **************************************************************************
|
||||
|
||||
class UserQuery extends Query<User, UserQueryWhere> {
|
||||
UserQuery() {}
|
||||
UserQuery() {
|
||||
_where = new UserQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final UserQueryValues values = new UserQueryValues();
|
||||
|
||||
@override
|
||||
final UserQueryWhere where = new UserQueryWhere();
|
||||
UserQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -88,9 +89,14 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
];
|
||||
}
|
||||
|
||||
@override
|
||||
UserQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
UserQueryWhere newWhereClause() {
|
||||
return new UserQueryWhere();
|
||||
return new UserQueryWhere(this);
|
||||
}
|
||||
|
||||
static User parseRow(List row) {
|
||||
|
@ -154,23 +160,25 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
class UserQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
UserQueryWhere(UserQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
username = new StringSqlExpressionBuilder(query, 'username'),
|
||||
password = new StringSqlExpressionBuilder(query, 'password'),
|
||||
email = new StringSqlExpressionBuilder(query, 'email'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final StringSqlExpressionBuilder username =
|
||||
new StringSqlExpressionBuilder('username');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final StringSqlExpressionBuilder password =
|
||||
new StringSqlExpressionBuilder('password');
|
||||
final StringSqlExpressionBuilder username;
|
||||
|
||||
final StringSqlExpressionBuilder email =
|
||||
new StringSqlExpressionBuilder('email');
|
||||
final StringSqlExpressionBuilder password;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final StringSqlExpressionBuilder email;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -183,32 +191,32 @@ class UserQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
String get username {
|
||||
return (values['username'] as String);
|
||||
}
|
||||
|
||||
void set username(String value) => values['username'] = value;
|
||||
set username(String value) => values['username'] = value;
|
||||
String get password {
|
||||
return (values['password'] as String);
|
||||
}
|
||||
|
||||
void set password(String value) => values['password'] = value;
|
||||
set password(String value) => values['password'] = value;
|
||||
String get email {
|
||||
return (values['email'] as String);
|
||||
}
|
||||
|
||||
void set email(String value) => values['email'] = value;
|
||||
set email(String value) => values['email'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(User model) {
|
||||
values.addAll({
|
||||
'username': model.username,
|
||||
|
@ -221,13 +229,14 @@ class UserQueryValues extends MapQueryValues {
|
|||
}
|
||||
|
||||
class RoleQuery extends Query<Role, RoleQueryWhere> {
|
||||
RoleQuery() {}
|
||||
RoleQuery() {
|
||||
_where = new RoleQueryWhere(this);
|
||||
}
|
||||
|
||||
@override
|
||||
final RoleQueryValues values = new RoleQueryValues();
|
||||
|
||||
@override
|
||||
final RoleQueryWhere where = new RoleQueryWhere();
|
||||
RoleQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -239,9 +248,14 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
return const ['id', 'name', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
@override
|
||||
RoleQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
RoleQueryWhere newWhereClause() {
|
||||
return new RoleQueryWhere();
|
||||
return new RoleQueryWhere(this);
|
||||
}
|
||||
|
||||
static Role parseRow(List row) {
|
||||
|
@ -303,17 +317,19 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
class RoleQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
RoleQueryWhere(RoleQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
name = new StringSqlExpressionBuilder(query, 'name'),
|
||||
createdAt = new DateTimeSqlExpressionBuilder(query, 'created_at'),
|
||||
updatedAt = new DateTimeSqlExpressionBuilder(query, 'updated_at');
|
||||
|
||||
final StringSqlExpressionBuilder name =
|
||||
new StringSqlExpressionBuilder('name');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final DateTimeSqlExpressionBuilder createdAt =
|
||||
new DateTimeSqlExpressionBuilder('created_at');
|
||||
final StringSqlExpressionBuilder name;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt =
|
||||
new DateTimeSqlExpressionBuilder('updated_at');
|
||||
final DateTimeSqlExpressionBuilder createdAt;
|
||||
|
||||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -326,22 +342,22 @@ class RoleQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
String get name {
|
||||
return (values['name'] as String);
|
||||
}
|
||||
|
||||
void set name(String value) => values['name'] = value;
|
||||
set name(String value) => values['name'] = value;
|
||||
DateTime get createdAt {
|
||||
return (values['created_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set createdAt(DateTime value) => values['created_at'] = value;
|
||||
set createdAt(DateTime value) => values['created_at'] = value;
|
||||
DateTime get updatedAt {
|
||||
return (values['updated_at'] as DateTime);
|
||||
}
|
||||
|
||||
void set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
set updatedAt(DateTime value) => values['updated_at'] = value;
|
||||
void copyFrom(Role model) {
|
||||
values.addAll({
|
||||
'name': model.name,
|
||||
|
@ -353,6 +369,7 @@ class RoleQueryValues extends MapQueryValues {
|
|||
|
||||
class UserRoleQuery extends Query<UserRole, UserRoleQueryWhere> {
|
||||
UserRoleQuery() {
|
||||
_where = new UserRoleQueryWhere(this);
|
||||
leftJoin('users', 'user_id', 'id', additionalFields: const [
|
||||
'username',
|
||||
'password',
|
||||
|
@ -367,8 +384,7 @@ class UserRoleQuery extends Query<UserRole, UserRoleQueryWhere> {
|
|||
@override
|
||||
final UserRoleQueryValues values = new UserRoleQueryValues();
|
||||
|
||||
@override
|
||||
final UserRoleQueryWhere where = new UserRoleQueryWhere();
|
||||
UserRoleQueryWhere _where;
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
|
@ -380,9 +396,14 @@ class UserRoleQuery extends Query<UserRole, UserRoleQueryWhere> {
|
|||
return const ['id', 'user_id', 'role_id'];
|
||||
}
|
||||
|
||||
@override
|
||||
UserRoleQueryWhere get where {
|
||||
return _where;
|
||||
}
|
||||
|
||||
@override
|
||||
UserRoleQueryWhere newWhereClause() {
|
||||
return new UserRoleQueryWhere();
|
||||
return new UserRoleQueryWhere(this);
|
||||
}
|
||||
|
||||
static UserRole parseRow(List row) {
|
||||
|
@ -412,14 +433,16 @@ class UserRoleQuery extends Query<UserRole, UserRoleQueryWhere> {
|
|||
}
|
||||
|
||||
class UserRoleQueryWhere extends QueryWhere {
|
||||
final NumericSqlExpressionBuilder<int> id =
|
||||
new NumericSqlExpressionBuilder<int>('id');
|
||||
UserRoleQueryWhere(UserRoleQuery query)
|
||||
: id = new NumericSqlExpressionBuilder<int>(query, 'id'),
|
||||
userId = new NumericSqlExpressionBuilder<int>(query, 'user_id'),
|
||||
roleId = new NumericSqlExpressionBuilder<int>(query, 'role_id');
|
||||
|
||||
final NumericSqlExpressionBuilder<int> userId =
|
||||
new NumericSqlExpressionBuilder<int>('user_id');
|
||||
final NumericSqlExpressionBuilder<int> id;
|
||||
|
||||
final NumericSqlExpressionBuilder<int> roleId =
|
||||
new NumericSqlExpressionBuilder<int>('role_id');
|
||||
final NumericSqlExpressionBuilder<int> userId;
|
||||
|
||||
final NumericSqlExpressionBuilder<int> roleId;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
|
@ -432,17 +455,17 @@ class UserRoleQueryValues extends MapQueryValues {
|
|||
return (values['id'] as int);
|
||||
}
|
||||
|
||||
void set id(int value) => values['id'] = value;
|
||||
set id(int value) => values['id'] = value;
|
||||
int get userId {
|
||||
return (values['user_id'] as int);
|
||||
}
|
||||
|
||||
void set userId(int value) => values['user_id'] = value;
|
||||
set userId(int value) => values['user_id'] = value;
|
||||
int get roleId {
|
||||
return (values['role_id'] as int);
|
||||
}
|
||||
|
||||
void set roleId(int value) => values['role_id'] = value;
|
||||
set roleId(int value) => values['role_id'] = value;
|
||||
void copyFrom(UserRole model) {
|
||||
values.addAll({'id': model.id});
|
||||
if (model.user != null) {
|
||||
|
|
|
@ -78,7 +78,7 @@ main() {
|
|||
});
|
||||
|
||||
test('union', () async {
|
||||
var query1 = new CarQuery()..where.make.like('%Fer%');
|
||||
var query1 = new CarQuery()..where.make.like((_) => '%Fer%');
|
||||
var query2 = new CarQuery()..where.familyFriendly.isTrue;
|
||||
var query3 = new CarQuery()..where.description.equals('Submarine');
|
||||
var union = query1.union(query2).unionAll(query3);
|
||||
|
@ -89,7 +89,7 @@ main() {
|
|||
|
||||
test('or clause', () async {
|
||||
var query = new CarQuery()
|
||||
..where.make.like('Fer%')
|
||||
..where.make.like((_) => 'Fer%')
|
||||
..orWhere((where) => where
|
||||
..familyFriendly.isTrue
|
||||
..make.equals('Honda'));
|
||||
|
|
Loading…
Reference in a new issue