Run build_runner in Travis

This commit is contained in:
Tobe O 2019-02-06 22:38:34 -05:00
parent f25da02585
commit bad0200c92
14 changed files with 3390 additions and 4 deletions

View file

@ -34,6 +34,6 @@ dev_dependencies:
collection: ^1.0.0
postgres: ^1.0.0
test: ^1.0.0
dependency_overrides:
angel_orm:
path: ../angel_orm
# dependency_overrides:
# angel_orm:
# path: ../angel_orm

View file

@ -0,0 +1,245 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm.generator.models.author;
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class AuthorMigration extends Migration {
@override
up(Schema schema) {
schema.create('authors', (table) {
table.serial('id')..primaryKey();
table.varChar('name')..defaultsTo('Tobe Osakwe');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('authors');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class AuthorQuery extends Query<Author, AuthorQueryWhere> {
AuthorQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = AuthorQueryWhere(this);
}
@override
final AuthorQueryValues values = AuthorQueryValues();
AuthorQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'authors';
}
@override
get fields {
return const ['id', 'name', 'created_at', 'updated_at'];
}
@override
AuthorQueryWhere get where {
return _where;
}
@override
AuthorQueryWhere newWhereClause() {
return AuthorQueryWhere(this);
}
static Author parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Author(
id: row[0].toString(),
name: (row[1] as String),
createdAt: (row[2] as DateTime),
updatedAt: (row[3] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class AuthorQueryWhere extends QueryWhere {
AuthorQueryWhere(AuthorQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
name = StringSqlExpressionBuilder(query, 'name'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final StringSqlExpressionBuilder name;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, name, createdAt, updatedAt];
}
}
class AuthorQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
String get name {
return (values['name'] as String);
}
set name(String value) => values['name'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Author model) {
name = model.name;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Author extends _Author {
Author(
{this.id,
@required this.name = 'Tobe Osakwe',
this.createdAt,
this.updatedAt});
@override
final String id;
@override
final String name;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Author copyWith(
{String id, String name, DateTime createdAt, DateTime updatedAt}) {
return new Author(
id: id ?? this.id,
name: name ?? this.name,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Author &&
other.id == id &&
other.name == name &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, name, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return AuthorSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class AuthorSerializer {
static Author fromMap(Map map) {
if (map['name'] == null) {
throw new FormatException("Missing required field 'name' on Author.");
}
return new Author(
id: map['id'] as String,
name: map['name'] as String ?? 'Tobe Osakwe',
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Author model) {
if (model == null) {
return null;
}
if (model.name == null) {
throw new FormatException("Missing required field 'name' on Author.");
}
return {
'id': model.id,
'name': model.name,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class AuthorFields {
static const List<String> allFields = <String>[
id,
name,
createdAt,
updatedAt
];
static const String id = 'id';
static const String name = 'name';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,211 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm.generator.models.book;
// **************************************************************************
// OrmGenerator
// **************************************************************************
class BookQuery extends Query<Book, BookQueryWhere> {
BookQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = BookQueryWhere(this);
}
@override
final BookQueryValues values = BookQueryValues();
BookQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'books';
}
@override
get fields {
return const ['id'];
}
@override
BookQueryWhere get where {
return _where;
}
@override
BookQueryWhere newWhereClause() {
return BookQueryWhere(this);
}
static Book parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Book(id: row[0].toString());
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class BookQueryWhere extends QueryWhere {
BookQueryWhere(BookQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id');
final NumericSqlExpressionBuilder<int> id;
@override
get expressionBuilders {
return [id];
}
}
class BookQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
void copyFrom(Book model) {}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Book extends _Book {
Book(
{this.id,
this.author,
this.partnerAuthor,
this.name,
this.createdAt,
this.updatedAt});
@override
final String id;
@override
final dynamic author;
@override
final dynamic partnerAuthor;
@override
final String name;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Book copyWith(
{String id,
dynamic author,
dynamic partnerAuthor,
String name,
DateTime createdAt,
DateTime updatedAt}) {
return new Book(
id: id ?? this.id,
author: author ?? this.author,
partnerAuthor: partnerAuthor ?? this.partnerAuthor,
name: name ?? this.name,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Book &&
other.id == id &&
other.author == author &&
other.partnerAuthor == partnerAuthor &&
other.name == name &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, author, partnerAuthor, name, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return BookSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class BookSerializer {
static Book fromMap(Map map) {
return new Book(
id: map['id'] as String,
author: map['author'] as dynamic,
partnerAuthor: map['partner_author'] as dynamic,
name: map['name'] as String,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Book model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'author': model.author,
'partner_author': model.partnerAuthor,
'name': model.name,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class BookFields {
static const List<String> allFields = <String>[
id,
author,
partnerAuthor,
name,
createdAt,
updatedAt
];
static const String id = 'id';
static const String author = 'author';
static const String partnerAuthor = 'partner_author';
static const String name = 'name';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,337 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm.generator.models.car;
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class CarMigration extends Migration {
@override
up(Schema schema) {
schema.create('cars', (table) {
table.serial('id')..primaryKey();
table.varChar('make');
table.varChar('description');
table.boolean('family_friendly');
table.timeStamp('recalled_at');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('cars');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class CarQuery extends Query<Car, CarQueryWhere> {
CarQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = CarQueryWhere(this);
}
@override
final CarQueryValues values = CarQueryValues();
CarQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'cars';
}
@override
get fields {
return const [
'id',
'make',
'description',
'family_friendly',
'recalled_at',
'created_at',
'updated_at'
];
}
@override
CarQueryWhere get where {
return _where;
}
@override
CarQueryWhere newWhereClause() {
return CarQueryWhere(this);
}
static Car parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Car(
id: row[0].toString(),
make: (row[1] as String),
description: (row[2] as String),
familyFriendly: (row[3] as bool),
recalledAt: (row[4] as DateTime),
createdAt: (row[5] as DateTime),
updatedAt: (row[6] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class CarQueryWhere extends QueryWhere {
CarQueryWhere(CarQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
make = StringSqlExpressionBuilder(query, 'make'),
description = StringSqlExpressionBuilder(query, 'description'),
familyFriendly = BooleanSqlExpressionBuilder(query, 'family_friendly'),
recalledAt = DateTimeSqlExpressionBuilder(query, 'recalled_at'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final StringSqlExpressionBuilder make;
final StringSqlExpressionBuilder description;
final BooleanSqlExpressionBuilder familyFriendly;
final DateTimeSqlExpressionBuilder recalledAt;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [
id,
make,
description,
familyFriendly,
recalledAt,
createdAt,
updatedAt
];
}
}
class CarQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
String get make {
return (values['make'] as String);
}
set make(String value) => values['make'] = value;
String get description {
return (values['description'] as String);
}
set description(String value) => values['description'] = value;
bool get familyFriendly {
return (values['family_friendly'] as bool);
}
set familyFriendly(bool value) => values['family_friendly'] = value;
DateTime get recalledAt {
return (values['recalled_at'] as DateTime);
}
set recalledAt(DateTime value) => values['recalled_at'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Car model) {
make = model.make;
description = model.description;
familyFriendly = model.familyFriendly;
recalledAt = model.recalledAt;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Car extends _Car {
Car(
{this.id,
this.make,
this.description,
this.familyFriendly,
this.recalledAt,
this.createdAt,
this.updatedAt});
@override
final String id;
@override
final String make;
@override
final String description;
@override
final bool familyFriendly;
@override
final DateTime recalledAt;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Car copyWith(
{String id,
String make,
String description,
bool familyFriendly,
DateTime recalledAt,
DateTime createdAt,
DateTime updatedAt}) {
return new Car(
id: id ?? this.id,
make: make ?? this.make,
description: description ?? this.description,
familyFriendly: familyFriendly ?? this.familyFriendly,
recalledAt: recalledAt ?? this.recalledAt,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Car &&
other.id == id &&
other.make == make &&
other.description == description &&
other.familyFriendly == familyFriendly &&
other.recalledAt == recalledAt &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([
id,
make,
description,
familyFriendly,
recalledAt,
createdAt,
updatedAt
]);
}
Map<String, dynamic> toJson() {
return CarSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class CarSerializer {
static Car fromMap(Map map) {
return new Car(
id: map['id'] as String,
make: map['make'] as String,
description: map['description'] as String,
familyFriendly: map['family_friendly'] as bool,
recalledAt: map['recalled_at'] != null
? (map['recalled_at'] is DateTime
? (map['recalled_at'] as DateTime)
: DateTime.parse(map['recalled_at'].toString()))
: null,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Car model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'make': model.make,
'description': model.description,
'family_friendly': model.familyFriendly,
'recalled_at': model.recalledAt?.toIso8601String(),
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class CarFields {
static const List<String> allFields = <String>[
id,
make,
description,
familyFriendly,
recalledAt,
createdAt,
updatedAt
];
static const String id = 'id';
static const String make = 'make';
static const String description = 'description';
static const String familyFriendly = 'family_friendly';
static const String recalledAt = 'recalled_at';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,207 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.customer;
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class CustomerMigration extends Migration {
@override
up(Schema schema) {
schema.create('customers', (table) {
table.serial('id')..primaryKey();
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('customers');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
CustomerQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = CustomerQueryWhere(this);
}
@override
final CustomerQueryValues values = CustomerQueryValues();
CustomerQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'customers';
}
@override
get fields {
return const ['id', 'created_at', 'updated_at'];
}
@override
CustomerQueryWhere get where {
return _where;
}
@override
CustomerQueryWhere newWhereClause() {
return CustomerQueryWhere(this);
}
static Customer parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Customer(
id: row[0].toString(),
createdAt: (row[1] as DateTime),
updatedAt: (row[2] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class CustomerQueryWhere extends QueryWhere {
CustomerQueryWhere(CustomerQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, createdAt, updatedAt];
}
}
class CustomerQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Customer model) {
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Customer extends _Customer {
Customer({this.id, this.createdAt, this.updatedAt});
@override
final String id;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Customer copyWith({String id, DateTime createdAt, DateTime updatedAt}) {
return new Customer(
id: id ?? this.id,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Customer &&
other.id == id &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return CustomerSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class CustomerSerializer {
static Customer fromMap(Map map) {
return new Customer(
id: map['id'] as String,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Customer model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class CustomerFields {
static const List<String> allFields = <String>[id, createdAt, updatedAt];
static const String id = 'id';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,258 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.foot;
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class FootMigration extends Migration {
@override
up(Schema schema) {
schema.create('feet', (table) {
table.serial('id')..primaryKey();
table.integer('leg_id');
table.declare('n_toes', ColumnType('decimal'));
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('feet');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class FootQuery extends Query<Foot, FootQueryWhere> {
FootQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = FootQueryWhere(this);
}
@override
final FootQueryValues values = FootQueryValues();
FootQueryWhere _where;
@override
get casts {
return {'n_toes': 'text'};
}
@override
get tableName {
return 'feet';
}
@override
get fields {
return const ['id', 'leg_id', 'n_toes', 'created_at', 'updated_at'];
}
@override
FootQueryWhere get where {
return _where;
}
@override
FootQueryWhere newWhereClause() {
return FootQueryWhere(this);
}
static Foot parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Foot(
id: row[0].toString(),
legId: (row[1] as int),
nToes: double.parse(row[2].toString()),
createdAt: (row[3] as DateTime),
updatedAt: (row[4] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class FootQueryWhere extends QueryWhere {
FootQueryWhere(FootQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
legId = NumericSqlExpressionBuilder<int>(query, 'leg_id'),
nToes = NumericSqlExpressionBuilder<double>(query, 'n_toes'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final NumericSqlExpressionBuilder<int> legId;
final NumericSqlExpressionBuilder<double> nToes;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, legId, nToes, createdAt, updatedAt];
}
}
class FootQueryValues extends MapQueryValues {
@override
get casts {
return {'n_toes': 'decimal'};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
int get legId {
return (values['leg_id'] as int);
}
set legId(int value) => values['leg_id'] = value;
double get nToes {
return double.parse((values['n_toes'] as String));
}
set nToes(double value) => values['n_toes'] = value.toString();
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Foot model) {
legId = model.legId;
nToes = model.nToes;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Foot extends _Foot {
Foot({this.id, this.legId, this.nToes, this.createdAt, this.updatedAt});
@override
final String id;
@override
final int legId;
@override
final double nToes;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Foot copyWith(
{String id,
int legId,
double nToes,
DateTime createdAt,
DateTime updatedAt}) {
return new Foot(
id: id ?? this.id,
legId: legId ?? this.legId,
nToes: nToes ?? this.nToes,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Foot &&
other.id == id &&
other.legId == legId &&
other.nToes == nToes &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, legId, nToes, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return FootSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class FootSerializer {
static Foot fromMap(Map map) {
return new Foot(
id: map['id'] as String,
legId: map['leg_id'] as int,
nToes: map['n_toes'] as double,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Foot model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'leg_id': model.legId,
'n_toes': model.nToes,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class FootFields {
static const List<String> allFields = <String>[
id,
legId,
nToes,
createdAt,
updatedAt
];
static const String id = 'id';
static const String legId = 'leg_id';
static const String nToes = 'n_toes';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,259 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.fruit;
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class FruitMigration extends Migration {
@override
up(Schema schema) {
schema.create('fruits', (table) {
table.serial('id')..primaryKey();
table.integer('tree_id');
table.varChar('common_name');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('fruits');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class FruitQuery extends Query<Fruit, FruitQueryWhere> {
FruitQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = FruitQueryWhere(this);
}
@override
final FruitQueryValues values = FruitQueryValues();
FruitQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'fruits';
}
@override
get fields {
return const ['id', 'tree_id', 'common_name', 'created_at', 'updated_at'];
}
@override
FruitQueryWhere get where {
return _where;
}
@override
FruitQueryWhere newWhereClause() {
return FruitQueryWhere(this);
}
static Fruit parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Fruit(
id: row[0].toString(),
treeId: (row[1] as int),
commonName: (row[2] as String),
createdAt: (row[3] as DateTime),
updatedAt: (row[4] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class FruitQueryWhere extends QueryWhere {
FruitQueryWhere(FruitQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
treeId = NumericSqlExpressionBuilder<int>(query, 'tree_id'),
commonName = StringSqlExpressionBuilder(query, 'common_name'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final NumericSqlExpressionBuilder<int> treeId;
final StringSqlExpressionBuilder commonName;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, treeId, commonName, createdAt, updatedAt];
}
}
class FruitQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
int get treeId {
return (values['tree_id'] as int);
}
set treeId(int value) => values['tree_id'] = value;
String get commonName {
return (values['common_name'] as String);
}
set commonName(String value) => values['common_name'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Fruit model) {
treeId = model.treeId;
commonName = model.commonName;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Fruit extends _Fruit {
Fruit(
{this.id, this.treeId, this.commonName, this.createdAt, this.updatedAt});
@override
final String id;
@override
final int treeId;
@override
final String commonName;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Fruit copyWith(
{String id,
int treeId,
String commonName,
DateTime createdAt,
DateTime updatedAt}) {
return new Fruit(
id: id ?? this.id,
treeId: treeId ?? this.treeId,
commonName: commonName ?? this.commonName,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Fruit &&
other.id == id &&
other.treeId == treeId &&
other.commonName == commonName &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, treeId, commonName, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return FruitSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class FruitSerializer {
static Fruit fromMap(Map map) {
return new Fruit(
id: map['id'] as String,
treeId: map['tree_id'] as int,
commonName: map['common_name'] as String,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Fruit model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'tree_id': model.treeId,
'common_name': model.commonName,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class FruitFields {
static const List<String> allFields = <String>[
id,
treeId,
commonName,
createdAt,
updatedAt
];
static const String id = 'id';
static const String treeId = 'tree_id';
static const String commonName = 'common_name';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,243 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'has_car.dart';
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class HasCarMigration extends Migration {
@override
up(Schema schema) {
schema.create('has_cars', (table) {
table.serial('id')..primaryKey();
table.integer('type');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('has_cars');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
HasCarQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = HasCarQueryWhere(this);
}
@override
final HasCarQueryValues values = HasCarQueryValues();
HasCarQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'has_cars';
}
@override
get fields {
return const ['id', 'type', 'created_at', 'updated_at'];
}
@override
HasCarQueryWhere get where {
return _where;
}
@override
HasCarQueryWhere newWhereClause() {
return HasCarQueryWhere(this);
}
static HasCar parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = HasCar(
id: row[0].toString(),
type: CarType.values[(row[1] as int)],
createdAt: (row[2] as DateTime),
updatedAt: (row[3] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class HasCarQueryWhere extends QueryWhere {
HasCarQueryWhere(HasCarQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
type = EnumSqlExpressionBuilder<CarType>(query, 'type', (v) => v.index),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final EnumSqlExpressionBuilder<CarType> type;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, type, createdAt, updatedAt];
}
}
class HasCarQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
CarType get type {
return CarType.values[(values['type'] as int)];
}
set type(CarType value) => values['type'] = value.index;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(HasCar model) {
type = model.type;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class HasCar extends _HasCar {
HasCar({this.id, @required this.type, this.createdAt, this.updatedAt});
@override
final String id;
@override
final CarType type;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
HasCar copyWith(
{String id, CarType type, DateTime createdAt, DateTime updatedAt}) {
return new HasCar(
id: id ?? this.id,
type: type ?? this.type,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _HasCar &&
other.id == id &&
other.type == type &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, type, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return HasCarSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class HasCarSerializer {
static HasCar fromMap(Map map) {
if (map['type'] == null) {
throw new FormatException("Missing required field 'type' on HasCar.");
}
return new HasCar(
id: map['id'] as String,
type: map['type'] is CarType
? (map['type'] as CarType)
: (map['type'] is int ? CarType.values[map['type'] as int] : null),
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_HasCar model) {
if (model == null) {
return null;
}
if (model.type == null) {
throw new FormatException("Missing required field 'type' on HasCar.");
}
return {
'id': model.id,
'type': model.type == null ? null : CarType.values.indexOf(model.type),
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class HasCarFields {
static const List<String> allFields = <String>[
id,
type,
createdAt,
updatedAt
];
static const String id = 'id';
static const String type = 'type';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,182 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of 'has_map.dart';
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class HasMapMigration extends Migration {
@override
up(Schema schema) {
schema.create('has_maps', (table) {
table.declare('value', ColumnType('jsonb'));
table.declare('list', ColumnType('jsonb'));
});
}
@override
down(Schema schema) {
schema.drop('has_maps');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class HasMapQuery extends Query<HasMap, HasMapQueryWhere> {
HasMapQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = HasMapQueryWhere(this);
}
@override
final HasMapQueryValues values = HasMapQueryValues();
HasMapQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'has_maps';
}
@override
get fields {
return const ['value', 'list'];
}
@override
HasMapQueryWhere get where {
return _where;
}
@override
HasMapQueryWhere newWhereClause() {
return HasMapQueryWhere(this);
}
static HasMap parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = HasMap(
value: (row[0] as Map<dynamic, dynamic>),
list: (row[1] as List<dynamic>));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class HasMapQueryWhere extends QueryWhere {
HasMapQueryWhere(HasMapQuery query)
: value = MapSqlExpressionBuilder(query, 'value'),
list = ListSqlExpressionBuilder(query, 'list');
final MapSqlExpressionBuilder value;
final ListSqlExpressionBuilder list;
@override
get expressionBuilders {
return [value, list];
}
}
class HasMapQueryValues extends MapQueryValues {
@override
get casts {
return {'list': 'jsonb'};
}
Map<dynamic, dynamic> get value {
return (values['value'] as Map<dynamic, dynamic>);
}
set value(Map<dynamic, dynamic> value) => values['value'] = value;
List<dynamic> get list {
return (json.decode((values['list'] as String)) as List);
}
set list(List<dynamic> value) => values['list'] = json.encode(value);
void copyFrom(HasMap model) {
value = model.value;
list = model.list;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class HasMap implements _HasMap {
const HasMap({Map<dynamic, dynamic> this.value, List<dynamic> this.list});
@override
final Map<dynamic, dynamic> value;
@override
final List<dynamic> list;
HasMap copyWith({Map<dynamic, dynamic> value, List<dynamic> list}) {
return new HasMap(value: value ?? this.value, list: list ?? this.list);
}
bool operator ==(other) {
return other is _HasMap &&
const MapEquality<dynamic, dynamic>(
keys: const DefaultEquality(), values: const DefaultEquality())
.equals(other.value, value) &&
const ListEquality<dynamic>(const DefaultEquality())
.equals(other.list, list);
}
@override
int get hashCode {
return hashObjects([value, list]);
}
Map<String, dynamic> toJson() {
return HasMapSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class HasMapSerializer {
static HasMap fromMap(Map map) {
return new HasMap(
value: map['value'] is Map
? (map['value'] as Map).cast<dynamic, dynamic>()
: null,
list: map['list'] is Iterable
? (map['list'] as Iterable).cast<dynamic>().toList()
: null);
}
static Map<String, dynamic> toMap(_HasMap model) {
if (model == null) {
return null;
}
return {'value': model.value, 'list': model.list};
}
}
abstract class HasMapFields {
static const List<String> allFields = <String>[value, list];
static const String value = 'value';
static const String list = 'list';
}

View file

@ -0,0 +1,194 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.leg;
// **************************************************************************
// OrmGenerator
// **************************************************************************
class LegQuery extends Query<Leg, LegQueryWhere> {
LegQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = LegQueryWhere(this);
}
@override
final LegQueryValues values = LegQueryValues();
LegQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'legs';
}
@override
get fields {
return const ['id'];
}
@override
LegQueryWhere get where {
return _where;
}
@override
LegQueryWhere newWhereClause() {
return LegQueryWhere(this);
}
static Leg parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Leg(id: row[0].toString());
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class LegQueryWhere extends QueryWhere {
LegQueryWhere(LegQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id');
final NumericSqlExpressionBuilder<int> id;
@override
get expressionBuilders {
return [id];
}
}
class LegQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
void copyFrom(Leg model) {}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Leg extends _Leg {
Leg({this.id, this.foot, this.name, this.createdAt, this.updatedAt});
@override
final String id;
@override
final dynamic foot;
@override
final String name;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Leg copyWith(
{String id,
dynamic foot,
String name,
DateTime createdAt,
DateTime updatedAt}) {
return new Leg(
id: id ?? this.id,
foot: foot ?? this.foot,
name: name ?? this.name,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Leg &&
other.id == id &&
other.foot == foot &&
other.name == name &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, foot, name, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return LegSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class LegSerializer {
static Leg fromMap(Map map) {
return new Leg(
id: map['id'] as String,
foot: map['foot'] as dynamic,
name: map['name'] as String,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Leg model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'foot': model.foot,
'name': model.name,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class LegFields {
static const List<String> allFields = <String>[
id,
foot,
name,
createdAt,
updatedAt
];
static const String id = 'id';
static const String foot = 'foot';
static const String name = 'name';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,228 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.order;
// **************************************************************************
// OrmGenerator
// **************************************************************************
class OrderQuery extends Query<Order, OrderQueryWhere> {
OrderQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = OrderQueryWhere(this);
}
@override
final OrderQueryValues values = OrderQueryValues();
OrderQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'orders';
}
@override
get fields {
return const ['id'];
}
@override
OrderQueryWhere get where {
return _where;
}
@override
OrderQueryWhere newWhereClause() {
return OrderQueryWhere(this);
}
static Order parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Order(id: row[0].toString());
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class OrderQueryWhere extends QueryWhere {
OrderQueryWhere(OrderQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id');
final NumericSqlExpressionBuilder<int> id;
@override
get expressionBuilders {
return [id];
}
}
class OrderQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
void copyFrom(Order model) {}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Order extends _Order {
Order(
{this.id,
this.customer,
this.employeeId,
this.orderDate,
this.shipperId,
this.createdAt,
this.updatedAt});
@override
final String id;
@override
final dynamic customer;
@override
final int employeeId;
@override
final DateTime orderDate;
@override
final int shipperId;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Order copyWith(
{String id,
dynamic customer,
int employeeId,
DateTime orderDate,
int shipperId,
DateTime createdAt,
DateTime updatedAt}) {
return new Order(
id: id ?? this.id,
customer: customer ?? this.customer,
employeeId: employeeId ?? this.employeeId,
orderDate: orderDate ?? this.orderDate,
shipperId: shipperId ?? this.shipperId,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Order &&
other.id == id &&
other.customer == customer &&
other.employeeId == employeeId &&
other.orderDate == orderDate &&
other.shipperId == shipperId &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects(
[id, customer, employeeId, orderDate, shipperId, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return OrderSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class OrderSerializer {
static Order fromMap(Map map) {
return new Order(
id: map['id'] as String,
customer: map['customer'] as dynamic,
employeeId: map['employee_id'] as int,
orderDate: map['order_date'] != null
? (map['order_date'] is DateTime
? (map['order_date'] as DateTime)
: DateTime.parse(map['order_date'].toString()))
: null,
shipperId: map['shipper_id'] as int,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Order model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'customer': model.customer,
'employee_id': model.employeeId,
'order_date': model.orderDate?.toIso8601String(),
'shipper_id': model.shipperId,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class OrderFields {
static const List<String> allFields = <String>[
id,
customer,
employeeId,
orderDate,
shipperId,
createdAt,
updatedAt
];
static const String id = 'id';
static const String customer = 'customer';
static const String employeeId = 'employee_id';
static const String orderDate = 'order_date';
static const String shipperId = 'shipper_id';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,213 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.tree;
// **************************************************************************
// OrmGenerator
// **************************************************************************
class TreeQuery extends Query<Tree, TreeQueryWhere> {
TreeQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = TreeQueryWhere(this);
}
@override
final TreeQueryValues values = TreeQueryValues();
TreeQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'trees';
}
@override
get fields {
return const ['id', 'rings'];
}
@override
TreeQueryWhere get where {
return _where;
}
@override
TreeQueryWhere newWhereClause() {
return TreeQueryWhere(this);
}
static Tree parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Tree(id: row[0].toString(), rings: (row[1] as int));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class TreeQueryWhere extends QueryWhere {
TreeQueryWhere(TreeQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
rings = NumericSqlExpressionBuilder<int>(query, 'rings');
final NumericSqlExpressionBuilder<int> id;
final NumericSqlExpressionBuilder<int> rings;
@override
get expressionBuilders {
return [id, rings];
}
}
class TreeQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
int get rings {
return (values['rings'] as int);
}
set rings(int value) => values['rings'] = value;
void copyFrom(Tree model) {
rings = model.rings;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class Tree extends _Tree {
Tree(
{this.id,
this.rings,
List<dynamic> fruits,
this.createdAt,
this.updatedAt})
: this.fruits = new List.unmodifiable(fruits ?? []);
@override
final String id;
@override
final int rings;
@override
final List<dynamic> fruits;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Tree copyWith(
{String id,
int rings,
List<dynamic> fruits,
DateTime createdAt,
DateTime updatedAt}) {
return new Tree(
id: id ?? this.id,
rings: rings ?? this.rings,
fruits: fruits ?? this.fruits,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Tree &&
other.id == id &&
other.rings == rings &&
const ListEquality<dynamic>(const DefaultEquality())
.equals(other.fruits, fruits) &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, rings, fruits, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return TreeSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class TreeSerializer {
static Tree fromMap(Map map) {
return new Tree(
id: map['id'] as String,
rings: map['rings'] as int,
fruits: map['fruits'] is Iterable
? (map['fruits'] as Iterable).cast<dynamic>().toList()
: null,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Tree model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'rings': model.rings,
'fruits': model.fruits,
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class TreeFields {
static const List<String> allFields = <String>[
id,
rings,
fruits,
createdAt,
updatedAt
];
static const String id = 'id';
static const String rings = 'rings';
static const String fruits = 'fruits';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -0,0 +1,809 @@
// GENERATED CODE - DO NOT MODIFY BY HAND
part of angel_orm_generator.test.models.user;
// **************************************************************************
// MigrationGenerator
// **************************************************************************
class UserMigration extends Migration {
@override
up(Schema schema) {
schema.create('users', (table) {
table.serial('id')..primaryKey();
table.varChar('username');
table.varChar('password');
table.varChar('email');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('users');
}
}
class RoleUserMigration extends Migration {
@override
up(Schema schema) {
schema.create('role_users', (table) {
table.serial('id')..primaryKey();
table.timeStamp('created_at');
table.timeStamp('updated_at');
table.integer('role_id').references('roles', 'id');
table.integer('user_id').references('users', 'id');
});
}
@override
down(Schema schema) {
schema.drop('role_users');
}
}
class RoleMigration extends Migration {
@override
up(Schema schema) {
schema.create('roles', (table) {
table.serial('id')..primaryKey();
table.varChar('name');
table.timeStamp('created_at');
table.timeStamp('updated_at');
});
}
@override
down(Schema schema) {
schema.drop('roles');
}
}
// **************************************************************************
// OrmGenerator
// **************************************************************************
class UserQuery extends Query<User, UserQueryWhere> {
UserQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = UserQueryWhere(this);
}
@override
final UserQueryValues values = UserQueryValues();
UserQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'users';
}
@override
get fields {
return const [
'id',
'username',
'password',
'email',
'created_at',
'updated_at'
];
}
@override
UserQueryWhere get where {
return _where;
}
@override
UserQueryWhere newWhereClause() {
return UserQueryWhere(this);
}
static User parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = User(
id: row[0].toString(),
username: (row[1] as String),
password: (row[2] as String),
email: (row[3] as String),
createdAt: (row[4] as DateTime),
updatedAt: (row[5] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class UserQueryWhere extends QueryWhere {
UserQueryWhere(UserQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
username = StringSqlExpressionBuilder(query, 'username'),
password = StringSqlExpressionBuilder(query, 'password'),
email = StringSqlExpressionBuilder(query, 'email'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final StringSqlExpressionBuilder username;
final StringSqlExpressionBuilder password;
final StringSqlExpressionBuilder email;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, username, password, email, createdAt, updatedAt];
}
}
class UserQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
String get username {
return (values['username'] as String);
}
set username(String value) => values['username'] = value;
String get password {
return (values['password'] as String);
}
set password(String value) => values['password'] = value;
String get email {
return (values['email'] as String);
}
set email(String value) => values['email'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(User model) {
username = model.username;
password = model.password;
email = model.email;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
class RoleUserQuery extends Query<RoleUser, RoleUserQueryWhere> {
RoleUserQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = RoleUserQueryWhere(this);
leftJoin('roles', 'role_id', 'id',
additionalFields: const ['id', 'name', 'created_at', 'updated_at']);
leftJoin('users', 'user_id', 'id', additionalFields: const [
'id',
'username',
'password',
'email',
'created_at',
'updated_at'
]);
}
@override
final RoleUserQueryValues values = RoleUserQueryValues();
RoleUserQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'role_users';
}
@override
get fields {
return const ['id', 'role_id', 'user_id', 'created_at', 'updated_at'];
}
@override
RoleUserQueryWhere get where {
return _where;
}
@override
RoleUserQueryWhere newWhereClause() {
return RoleUserQueryWhere(this);
}
static RoleUser parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = RoleUser(
id: row[0].toString(),
createdAt: (row[3] as DateTime),
updatedAt: (row[4] as DateTime));
if (row.length > 5) {
model = model.copyWith(role: RoleQuery.parseRow(row.skip(5).toList()));
}
if (row.length > 9) {
model = model.copyWith(user: UserQuery.parseRow(row.skip(9).toList()));
}
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class RoleUserQueryWhere extends QueryWhere {
RoleUserQueryWhere(RoleUserQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
roleId = NumericSqlExpressionBuilder<int>(query, 'role_id'),
userId = NumericSqlExpressionBuilder<int>(query, 'user_id'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final NumericSqlExpressionBuilder<int> roleId;
final NumericSqlExpressionBuilder<int> userId;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, roleId, userId, createdAt, updatedAt];
}
}
class RoleUserQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
int get roleId {
return (values['role_id'] as int);
}
set roleId(int value) => values['role_id'] = value;
int get userId {
return (values['user_id'] as int);
}
set userId(int value) => values['user_id'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(RoleUser model) {
createdAt = model.createdAt;
updatedAt = model.updatedAt;
if (model.role != null) {
values['role_id'] = int.parse(model.role.id);
}
if (model.user != null) {
values['user_id'] = int.parse(model.user.id);
}
}
}
class RoleQuery extends Query<Role, RoleQueryWhere> {
RoleQuery({Set<String> trampoline}) {
trampoline ??= Set();
trampoline.add(tableName);
_where = RoleQueryWhere(this);
}
@override
final RoleQueryValues values = RoleQueryValues();
RoleQueryWhere _where;
@override
get casts {
return {};
}
@override
get tableName {
return 'roles';
}
@override
get fields {
return const ['id', 'name', 'created_at', 'updated_at'];
}
@override
RoleQueryWhere get where {
return _where;
}
@override
RoleQueryWhere newWhereClause() {
return RoleQueryWhere(this);
}
static Role parseRow(List row) {
if (row.every((x) => x == null)) return null;
var model = Role(
id: row[0].toString(),
name: (row[1] as String),
createdAt: (row[2] as DateTime),
updatedAt: (row[3] as DateTime));
return model;
}
@override
deserialize(List row) {
return parseRow(row);
}
}
class RoleQueryWhere extends QueryWhere {
RoleQueryWhere(RoleQuery query)
: id = NumericSqlExpressionBuilder<int>(query, 'id'),
name = StringSqlExpressionBuilder(query, 'name'),
createdAt = DateTimeSqlExpressionBuilder(query, 'created_at'),
updatedAt = DateTimeSqlExpressionBuilder(query, 'updated_at');
final NumericSqlExpressionBuilder<int> id;
final StringSqlExpressionBuilder name;
final DateTimeSqlExpressionBuilder createdAt;
final DateTimeSqlExpressionBuilder updatedAt;
@override
get expressionBuilders {
return [id, name, createdAt, updatedAt];
}
}
class RoleQueryValues extends MapQueryValues {
@override
get casts {
return {};
}
int get id {
return (values['id'] as int);
}
set id(int value) => values['id'] = value;
String get name {
return (values['name'] as String);
}
set name(String value) => values['name'] = value;
DateTime get createdAt {
return (values['created_at'] as DateTime);
}
set createdAt(DateTime value) => values['created_at'] = value;
DateTime get updatedAt {
return (values['updated_at'] as DateTime);
}
set updatedAt(DateTime value) => values['updated_at'] = value;
void copyFrom(Role model) {
name = model.name;
createdAt = model.createdAt;
updatedAt = model.updatedAt;
}
}
// **************************************************************************
// JsonModelGenerator
// **************************************************************************
@generatedSerializable
class User extends _User {
User(
{this.id,
this.username,
this.password,
this.email,
List<_Role> roles,
this.createdAt,
this.updatedAt})
: this.roles = new List.unmodifiable(roles ?? []);
@override
final String id;
@override
final String username;
@override
final String password;
@override
final String email;
@override
final List<_Role> roles;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
User copyWith(
{String id,
String username,
String password,
String email,
List<_Role> roles,
DateTime createdAt,
DateTime updatedAt}) {
return new User(
id: id ?? this.id,
username: username ?? this.username,
password: password ?? this.password,
email: email ?? this.email,
roles: roles ?? this.roles,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _User &&
other.id == id &&
other.username == username &&
other.password == password &&
other.email == email &&
const ListEquality<_Role>(const DefaultEquality<_Role>())
.equals(other.roles, roles) &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects(
[id, username, password, email, roles, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return UserSerializer.toMap(this);
}
}
@generatedSerializable
class RoleUser extends _RoleUser {
RoleUser({this.id, this.role, this.user, this.createdAt, this.updatedAt});
@override
final String id;
@override
final _Role role;
@override
final _User user;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
RoleUser copyWith(
{String id,
_Role role,
_User user,
DateTime createdAt,
DateTime updatedAt}) {
return new RoleUser(
id: id ?? this.id,
role: role ?? this.role,
user: user ?? this.user,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _RoleUser &&
other.id == id &&
other.role == role &&
other.user == user &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, role, user, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return RoleUserSerializer.toMap(this);
}
}
@generatedSerializable
class Role extends _Role {
Role({this.id, this.name, List<_User> users, this.createdAt, this.updatedAt})
: this.users = new List.unmodifiable(users ?? []);
@override
final String id;
@override
final String name;
@override
final List<_User> users;
@override
final DateTime createdAt;
@override
final DateTime updatedAt;
Role copyWith(
{String id,
String name,
List<_User> users,
DateTime createdAt,
DateTime updatedAt}) {
return new Role(
id: id ?? this.id,
name: name ?? this.name,
users: users ?? this.users,
createdAt: createdAt ?? this.createdAt,
updatedAt: updatedAt ?? this.updatedAt);
}
bool operator ==(other) {
return other is _Role &&
other.id == id &&
other.name == name &&
const ListEquality<_User>(const DefaultEquality<_User>())
.equals(other.users, users) &&
other.createdAt == createdAt &&
other.updatedAt == updatedAt;
}
@override
int get hashCode {
return hashObjects([id, name, users, createdAt, updatedAt]);
}
Map<String, dynamic> toJson() {
return RoleSerializer.toMap(this);
}
}
// **************************************************************************
// SerializerGenerator
// **************************************************************************
abstract class UserSerializer {
static User fromMap(Map map) {
return new User(
id: map['id'] as String,
username: map['username'] as String,
password: map['password'] as String,
email: map['email'] as String,
roles: map['roles'] is Iterable
? new List.unmodifiable(
((map['roles'] as Iterable).where((x) => x is Map))
.cast<Map>()
.map(RoleSerializer.fromMap))
: null,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_User model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'username': model.username,
'password': model.password,
'email': model.email,
'roles': model.roles?.map((m) => RoleSerializer.toMap(m))?.toList(),
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class UserFields {
static const List<String> allFields = <String>[
id,
username,
password,
email,
roles,
createdAt,
updatedAt
];
static const String id = 'id';
static const String username = 'username';
static const String password = 'password';
static const String email = 'email';
static const String roles = 'roles';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}
abstract class RoleUserSerializer {
static RoleUser fromMap(Map map) {
return new RoleUser(
id: map['id'] as String,
role: map['role'] != null
? RoleSerializer.fromMap(map['role'] as Map)
: null,
user: map['user'] != null
? UserSerializer.fromMap(map['user'] as Map)
: null,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_RoleUser model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'role': RoleSerializer.toMap(model.role),
'user': UserSerializer.toMap(model.user),
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class RoleUserFields {
static const List<String> allFields = <String>[
id,
role,
user,
createdAt,
updatedAt
];
static const String id = 'id';
static const String role = 'role';
static const String user = 'user';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}
abstract class RoleSerializer {
static Role fromMap(Map map) {
return new Role(
id: map['id'] as String,
name: map['name'] as String,
users: map['users'] is Iterable
? new List.unmodifiable(
((map['users'] as Iterable).where((x) => x is Map))
.cast<Map>()
.map(UserSerializer.fromMap))
: null,
createdAt: map['created_at'] != null
? (map['created_at'] is DateTime
? (map['created_at'] as DateTime)
: DateTime.parse(map['created_at'].toString()))
: null,
updatedAt: map['updated_at'] != null
? (map['updated_at'] is DateTime
? (map['updated_at'] as DateTime)
: DateTime.parse(map['updated_at'].toString()))
: null);
}
static Map<String, dynamic> toMap(_Role model) {
if (model == null) {
return null;
}
return {
'id': model.id,
'name': model.name,
'users': model.users?.map((m) => UserSerializer.toMap(m))?.toList(),
'created_at': model.createdAt?.toIso8601String(),
'updated_at': model.updatedAt?.toIso8601String()
};
}
}
abstract class RoleFields {
static const List<String> allFields = <String>[
id,
name,
users,
createdAt,
updatedAt
];
static const String id = 'id';
static const String name = 'name';
static const String users = 'users';
static const String createdAt = 'created_at';
static const String updatedAt = 'updated_at';
}

View file

@ -1,5 +1,5 @@
#!/usr/bin/env bash
cd angel_orm_generator
pub get
dart tool/build.dart
pub run build_runner build
POSTGRES_USERNAME="angel_orm" POSTGRES_PASSWORD="angel_orm" pub run test