Removed redundant code
This commit is contained in:
parent
7287bf12c1
commit
d5dba913af
73 changed files with 534 additions and 490 deletions
|
@ -107,12 +107,12 @@ class AuthToken {
|
|||
|
||||
Map toJson() {
|
||||
return _splayify({
|
||||
"iss": "angel_auth",
|
||||
"aud": ipAddress,
|
||||
"exp": lifeSpan,
|
||||
"iat": issuedAt.toIso8601String(),
|
||||
"sub": userId,
|
||||
"pld": _splayify(payload)
|
||||
'iss': 'angel_auth',
|
||||
'aud': ipAddress,
|
||||
'exp': lifeSpan,
|
||||
'iat': issuedAt.toIso8601String(),
|
||||
'sub': userId,
|
||||
'pld': _splayify(payload)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -81,7 +81,7 @@ class TwitterStrategy<User> extends AuthStrategy<User> {
|
|||
'accept': 'application/json'
|
||||
},
|
||||
body: {
|
||||
"oauth_callback": options.redirectUri.toString()
|
||||
'oauth_callback': options.redirectUri.toString()
|
||||
}).then(handleUrlEncodedResponse);
|
||||
}
|
||||
|
||||
|
@ -91,17 +91,18 @@ class TwitterStrategy<User> extends AuthStrategy<User> {
|
|||
try {
|
||||
if (options != null) {
|
||||
var result = await authenticateCallback(req, res, options);
|
||||
if (result is User)
|
||||
if (result is User) {
|
||||
return result;
|
||||
else
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
var result = await getRequestToken();
|
||||
var token = result['oauth_token'];
|
||||
var url = baseUrl.replace(
|
||||
path: p.join(baseUrl.path, 'oauth/authorize'),
|
||||
queryParameters: {'oauth_token': token});
|
||||
res.redirect(url);
|
||||
await res.redirect(url);
|
||||
return null;
|
||||
}
|
||||
} on TwitterAuthorizationException catch (e) {
|
||||
|
|
|
@ -391,8 +391,10 @@ final _data = <r.Reflectable, r.ReflectorData>{
|
|||
},
|
||||
{},
|
||||
{
|
||||
r"": (b) => ([length]) =>
|
||||
b ? (length == null ? List() : List(length)) : null,
|
||||
r"": (b) => ([length]) => b
|
||||
? (length == null ? [] : []
|
||||
..length)
|
||||
: null,
|
||||
r"filled": (b) => (length, fill, {growable: false}) =>
|
||||
b ? List.filled(length, fill, growable: growable) : null,
|
||||
r"from": (b) => (elements, {growable: true}) =>
|
||||
|
|
|
@ -164,7 +164,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
case HookedServiceEvent.removed:
|
||||
return beforeRemoved;
|
||||
default:
|
||||
throw ArgumentError('Invalid service method: ${name}');
|
||||
throw ArgumentError('Invalid service method: $name');
|
||||
}
|
||||
}).forEach((HookedServiceEventDispatcher<Id, Data, T> dispatcher) =>
|
||||
dispatcher.listen(listener));
|
||||
|
@ -188,7 +188,7 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
case HookedServiceEvent.removed:
|
||||
return afterRemoved;
|
||||
default:
|
||||
throw ArgumentError('Invalid service method: ${name}');
|
||||
throw ArgumentError('Invalid service method: $name');
|
||||
}
|
||||
}).forEach((HookedServiceEventDispatcher<Id, Data, T> dispatcher) =>
|
||||
dispatcher.listen(listener));
|
||||
|
|
|
@ -12,6 +12,8 @@ class HttpResponseContext extends ResponseContext<HttpResponse> {
|
|||
/// The underlying [HttpResponse] under this instance.
|
||||
@override
|
||||
final HttpResponse rawResponse;
|
||||
|
||||
@override
|
||||
Angel? app;
|
||||
|
||||
LockableBytesBuilder? _buffer;
|
||||
|
|
|
@ -13,6 +13,7 @@ final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
|
|||
|
||||
class Http2RequestContext extends RequestContext<ServerTransportStream?> {
|
||||
final StreamController<List<int>> _body = StreamController();
|
||||
@override
|
||||
final Container container;
|
||||
List<Cookie> _cookies = <Cookie>[];
|
||||
HttpHeaders? _headers;
|
||||
|
|
|
@ -6,6 +6,7 @@ import 'package:http2/transport.dart';
|
|||
import 'http2_request_context.dart';
|
||||
|
||||
class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
|
||||
@override
|
||||
final Angel? app;
|
||||
final ServerTransportStream stream;
|
||||
|
||||
|
|
|
@ -205,7 +205,7 @@ void main() {
|
|||
Header.ascii(':scheme', serverRoot.scheme),
|
||||
];
|
||||
|
||||
var stream = await connection.makeRequest(headers, endStream: true);
|
||||
var stream = connection.makeRequest(headers, endStream: true);
|
||||
|
||||
var bb = await stream.incomingMessages
|
||||
.where((s) => s is DataStreamMessage)
|
||||
|
|
|
@ -41,12 +41,12 @@ class Http2Client extends BaseClient {
|
|||
headers.add(Header.ascii(k, v));
|
||||
});
|
||||
|
||||
var stream = await connection.makeRequest(headers, endStream: body.isEmpty);
|
||||
var stream = connection.makeRequest(headers, endStream: body.isEmpty);
|
||||
|
||||
if (body.isNotEmpty) {
|
||||
stream.sendData(body, endStream: true);
|
||||
} else {
|
||||
(stream.outgoingMessages.close());
|
||||
await (stream.outgoingMessages.close());
|
||||
}
|
||||
|
||||
return stream;
|
||||
|
|
|
@ -70,9 +70,9 @@ parameterMetaTests() {
|
|||
test('injects header or throws', () async {
|
||||
// Invalid request
|
||||
var rq = MockHttpRequest('GET', Uri.parse('/header'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
var rs = rq.response;
|
||||
(http.handleRequest(rq));
|
||||
await (http.handleRequest(rq));
|
||||
|
||||
await printResponse(rs);
|
||||
expect(rs.statusCode, 400);
|
||||
|
@ -80,7 +80,7 @@ parameterMetaTests() {
|
|||
// Valid request
|
||||
rq = MockHttpRequest('GET', Uri.parse('/header'))
|
||||
..headers.add('x-foo', 'bar');
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
rs = rq.response;
|
||||
await (http.handleRequest(rq));
|
||||
|
||||
|
@ -93,9 +93,9 @@ parameterMetaTests() {
|
|||
test('injects session or throws', () async {
|
||||
// Invalid request
|
||||
var rq = MockHttpRequest('GET', Uri.parse('/session'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
var rs = rq.response;
|
||||
(http
|
||||
await (http
|
||||
.handleRequest(rq)
|
||||
.timeout(const Duration(seconds: 5))
|
||||
.catchError((_) => null));
|
||||
|
@ -105,9 +105,9 @@ parameterMetaTests() {
|
|||
|
||||
rq = MockHttpRequest('GET', Uri.parse('/session'));
|
||||
rq.session['foo'] = 'bar';
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
rs = rq.response;
|
||||
(http.handleRequest(rq));
|
||||
await (http.handleRequest(rq));
|
||||
|
||||
await printResponse(rs);
|
||||
expect(rs.statusCode, 200);
|
||||
|
@ -119,18 +119,18 @@ parameterMetaTests() {
|
|||
|
||||
test('pattern matching', () async {
|
||||
var rq = MockHttpRequest('GET', Uri.parse('/match?mode=pos'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
var rs = rq.response;
|
||||
(http.handleRequest(rq));
|
||||
await (http.handleRequest(rq));
|
||||
var body = await readResponse(rs);
|
||||
print('Body: $body');
|
||||
expect(rs.statusCode, 200);
|
||||
expect(body, json.encode('YES pos'));
|
||||
|
||||
rq = MockHttpRequest('GET', Uri.parse('/match?mode=neg'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
rs = rq.response;
|
||||
(http.handleRequest(rq));
|
||||
await (http.handleRequest(rq));
|
||||
body = await readResponse(rs);
|
||||
print('Body: $body');
|
||||
expect(rs.statusCode, 200);
|
||||
|
@ -138,9 +138,9 @@ parameterMetaTests() {
|
|||
|
||||
// Fallback
|
||||
rq = MockHttpRequest('GET', Uri.parse('/match?mode=ambi'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
rs = rq.response;
|
||||
(http.handleRequest(rq));
|
||||
await (http.handleRequest(rq));
|
||||
body = await readResponse(rs);
|
||||
print('Body: $body');
|
||||
expect(rs.statusCode, 200);
|
||||
|
|
|
@ -42,7 +42,7 @@ void main() {
|
|||
var app = Angel(reflector: MirrorsReflector());
|
||||
var http = AngelHttp(app);
|
||||
var rq = MockHttpRequest('GET', $foo);
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
var rs = rq.response;
|
||||
var req = await http.createRequestContext(rq, rs);
|
||||
var res = await http.createResponseContext(rq, rs);
|
||||
|
@ -94,7 +94,7 @@ void main() {
|
|||
var http = AngelHttp(app);
|
||||
app.get('/', ioc((String a) => a));
|
||||
var rq = MockHttpRequest('GET', Uri.parse('/'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
await http.handleRequest(rq);
|
||||
var body = await rq.response.transform(utf8.decoder).join();
|
||||
expect(body, json.encode('b'));
|
||||
|
@ -105,7 +105,7 @@ void main() {
|
|||
var http = AngelHttp(app);
|
||||
app.get($foo.path, (req, ResponseContext res) => res.serialize(null));
|
||||
var rq = MockHttpRequest('GET', $foo);
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
await http.handleRequest(rq);
|
||||
var body = await rq.response.transform(utf8.decoder).join();
|
||||
expect(body, 'x');
|
||||
|
@ -121,7 +121,7 @@ void main() {
|
|||
|
||||
setUp(() async {
|
||||
var rq = MockHttpRequest('GET', $foo);
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
req = await http.createRequestContext(rq, rq.response);
|
||||
res = await http.createResponseContext(rq, rq.response);
|
||||
});
|
||||
|
@ -178,8 +178,8 @@ void main() {
|
|||
test('can send json', () async {
|
||||
var rq = MockHttpRequest('GET', Uri(path: 'wtf'))
|
||||
..headers.set('accept', 'application/json');
|
||||
(rq.close());
|
||||
(http.handleRequest(rq));
|
||||
await (rq.close());
|
||||
await (http.handleRequest(rq));
|
||||
await rq.response.toList();
|
||||
expect(rq.response.statusCode, 403);
|
||||
expect(rq.response.headers.contentType!.mimeType, 'application/json');
|
||||
|
@ -188,8 +188,8 @@ void main() {
|
|||
test('can throw in finalizer', () async {
|
||||
var rq = MockHttpRequest('GET', Uri(path: 'wtf'))
|
||||
..headers.set('accept', 'application/json');
|
||||
(rq.close());
|
||||
(http.handleRequest(rq));
|
||||
await (rq.close());
|
||||
await (http.handleRequest(rq));
|
||||
await rq.response.toList();
|
||||
expect(rq.response.statusCode, 403);
|
||||
expect(rq.response.headers.contentType!.mimeType, 'application/json');
|
||||
|
@ -198,8 +198,8 @@ void main() {
|
|||
test('can send html', () async {
|
||||
var rq = MockHttpRequest('GET', Uri(path: 'wtf2'));
|
||||
rq.headers.set('accept', 'text/html');
|
||||
(rq.close());
|
||||
(http.handleRequest(rq));
|
||||
await (rq.close());
|
||||
await (http.handleRequest(rq));
|
||||
await rq.response.toList();
|
||||
expect(rq.response.statusCode, 403);
|
||||
expect(rq.response.headers.contentType?.mimeType, 'text/html');
|
||||
|
|
|
@ -77,7 +77,7 @@ void main() {
|
|||
|
||||
_expectHelloBye(String path) async {
|
||||
var rq = MockHttpRequest('GET', Uri.parse(path));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
await http.handleRequest(rq);
|
||||
var body = await rq.response.transform(utf8.decoder).join();
|
||||
expect(body, 'Hello, world!bye');
|
||||
|
@ -90,7 +90,7 @@ void main() {
|
|||
test('cannot write after close', () async {
|
||||
try {
|
||||
var rq = MockHttpRequest('GET', Uri.parse('/overwrite'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
await http.handleRequest(rq);
|
||||
var body = await rq.response.transform(utf8.decoder).join();
|
||||
|
||||
|
@ -105,7 +105,7 @@ void main() {
|
|||
test('res => addError', () async {
|
||||
try {
|
||||
var rq = MockHttpRequest('GET', Uri.parse('/error'));
|
||||
(rq.close());
|
||||
await (rq.close());
|
||||
await http.handleRequest(rq);
|
||||
var body = await rq.response.transform(utf8.decoder).join();
|
||||
throw 'addError should throw error; response: $body';
|
||||
|
|
|
@ -73,8 +73,12 @@ class RegularElement extends Element {
|
|||
final Token? gt2;
|
||||
final Token lt2, slash, lt, gt;
|
||||
|
||||
final Identifier tagName, tagName2;
|
||||
@override
|
||||
final Identifier tagName;
|
||||
final Identifier tagName2;
|
||||
@override
|
||||
final Iterable<Attribute> attributes;
|
||||
@override
|
||||
final Iterable<ElementChild> children;
|
||||
|
||||
RegularElement(this.lt, this.tagName, this.attributes, this.gt, this.children,
|
||||
|
|
|
@ -205,7 +205,7 @@ class Renderer {
|
|||
element.gt2);
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
var i = 0;
|
||||
for (var item in attribute.value!.compute(scope)) {
|
||||
var childScope = scope.createChild(values: {alias: item, indexAs: i++});
|
||||
renderElement(strippedElement, buffer, childScope, html5);
|
||||
|
@ -255,7 +255,7 @@ class Renderer {
|
|||
value: attribute.value?.compute(scope), constant: true);
|
||||
}
|
||||
|
||||
for (int i = 0; i < element.children.length; i++) {
|
||||
for (var i = 0; i < element.children.length; i++) {
|
||||
var child = element.children.elementAt(i);
|
||||
renderElementChild(
|
||||
element, child, buffer, scope, html5, i, element.children.length);
|
||||
|
|
|
@ -7,7 +7,7 @@ part of 'stateful.dart';
|
|||
// **************************************************************************
|
||||
|
||||
abstract class _StatefulAppJaelTemplate implements Component<_AppState> {
|
||||
Timer? get _timer;
|
||||
//Timer? get _timer;
|
||||
void beforeDestroy();
|
||||
@override
|
||||
DomNode render() {
|
||||
|
|
|
@ -12,7 +12,7 @@ import 'package:path/src/context.dart';
|
|||
/// Converts a [DartType] to a [TypeReference].
|
||||
TypeReference convertTypeReference(DartType? t) {
|
||||
return new TypeReference((b) {
|
||||
b..symbol = t!.name;
|
||||
b..symbol = t?.getDisplayString(withNullability: false);
|
||||
|
||||
if (t is InterfaceType) {
|
||||
b.types.addAll(t.typeArguments.map(convertTypeReference));
|
||||
|
|
|
@ -66,7 +66,7 @@ class DeviceCodeResponse {
|
|||
}
|
||||
|
||||
if (interval != null) out['interval'] = interval;
|
||||
if (expiresIn != null) out['expires_in'] = expiresIn;
|
||||
out['expires_in'] = expiresIn;
|
||||
|
||||
return out;
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ class PostgresMigrationRunner implements MigrationRunner {
|
|||
bool _connected = false;
|
||||
|
||||
PostgresMigrationRunner(this.connection,
|
||||
{Iterable<Migration> migrations = const [], bool connected: false}) {
|
||||
{Iterable<Migration> migrations = const [], bool connected = false}) {
|
||||
if (migrations.isNotEmpty == true) migrations.forEach(addMigration);
|
||||
_connected = connected == true;
|
||||
}
|
||||
|
|
|
@ -50,6 +50,7 @@ class Employee extends _Employee {
|
|||
updatedAt: updatedAt ?? this.updatedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Employee &&
|
||||
other.id == id &&
|
||||
|
|
|
@ -54,13 +54,13 @@ class NumericSqlExpressionBuilder<T extends num>
|
|||
return '$_op $v';
|
||||
}
|
||||
|
||||
operator <(T value) => _change('<', value);
|
||||
bool operator <(T value) => _change('<', value);
|
||||
|
||||
operator >(T value) => _change('>', value);
|
||||
bool operator >(T value) => _change('>', value);
|
||||
|
||||
operator <=(T value) => _change('<=', value);
|
||||
bool operator <=(T value) => _change('<=', value);
|
||||
|
||||
operator >=(T value) => _change('>=', value);
|
||||
bool operator >=(T value) => _change('>=', value);
|
||||
|
||||
void get isNull {
|
||||
_raw = 'IS NULL';
|
||||
|
@ -210,7 +210,7 @@ class StringSqlExpressionBuilder extends SqlExpressionBuilder<String> {
|
|||
String? compile() {
|
||||
if (_raw != null) return _raw;
|
||||
if (_value == null) return null;
|
||||
return "$_op @$substitution";
|
||||
return '$_op @$substitution';
|
||||
}
|
||||
|
||||
void isEmpty() => equals('');
|
||||
|
@ -254,7 +254,7 @@ class StringSqlExpressionBuilder extends SqlExpressionBuilder<String> {
|
|||
void isNotBetween(String lower, String upper) {
|
||||
query.substitutionValues[lowerName] = lower;
|
||||
query.substitutionValues[upperName] = upper;
|
||||
_raw = "NOT BETWEEN @$lowerName AND @$upperName";
|
||||
_raw = 'NOT BETWEEN @$lowerName AND @$upperName';
|
||||
_hasValue = true;
|
||||
}
|
||||
|
||||
|
@ -381,13 +381,13 @@ class DateTimeSqlExpressionBuilder extends SqlExpressionBuilder<DateTime> {
|
|||
return true;
|
||||
}
|
||||
|
||||
operator <(DateTime value) => _change('<', value, true);
|
||||
bool operator <(DateTime value) => _change('<', value, true);
|
||||
|
||||
operator <=(DateTime value) => _change('<=', value, true);
|
||||
bool operator <=(DateTime value) => _change('<=', value, true);
|
||||
|
||||
operator >(DateTime value) => _change('>', value, true);
|
||||
bool operator >(DateTime value) => _change('>', value, true);
|
||||
|
||||
operator >=(DateTime value) => _change('>=', value, true);
|
||||
bool operator >=(DateTime value) => _change('>=', value, true);
|
||||
|
||||
void equals(DateTime value, {bool includeTime = true}) {
|
||||
_change('=', value, includeTime != false);
|
||||
|
|
|
@ -13,7 +13,7 @@ class Union<T> extends QueryBase<T> {
|
|||
final String tableName;
|
||||
|
||||
Union(this.left, this.right, {this.all = false, String? tableName})
|
||||
: this.tableName = tableName ?? left.tableName {
|
||||
: tableName = tableName ?? left.tableName {
|
||||
substitutionValues
|
||||
..addAll(left.substitutionValues)
|
||||
..addAll(right.substitutionValues);
|
||||
|
|
|
@ -128,7 +128,7 @@ class EmployeeQueryWhere extends QueryWhere {
|
|||
|
||||
class EmployeeQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {'salary': 'decimal'};
|
||||
}
|
||||
|
||||
|
@ -235,6 +235,7 @@ class Employee extends _Employee {
|
|||
salary: salary ?? this.salary);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Employee &&
|
||||
other.id == id &&
|
||||
|
|
|
@ -8,10 +8,10 @@ part of 'main.dart';
|
|||
|
||||
class TodoMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('todos', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.boolean('is_complete')..defaultsTo(false);
|
||||
table.serial('id').primaryKey();
|
||||
table.boolean('is_complete').defaultsTo(false);
|
||||
table.varChar('text');
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
|
@ -19,7 +19,7 @@ class TodoMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('todos');
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class TodoMigration extends Migration {
|
|||
|
||||
class TodoQuery extends Query<Todo, TodoQueryWhere> {
|
||||
TodoQuery({Set<String>? trampoline}) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = TodoQueryWhere(this);
|
||||
}
|
||||
|
@ -41,17 +41,17 @@ class TodoQuery extends Query<Todo, TodoQueryWhere> {
|
|||
TodoQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'todos';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'is_complete', 'text', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
|
@ -101,14 +101,14 @@ class TodoQueryWhere extends QueryWhere {
|
|||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, isComplete, text, createdAt, updatedAt];
|
||||
}
|
||||
}
|
||||
|
||||
class TodoQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ class Todo extends _Todo {
|
|||
String? text,
|
||||
DateTime? createdAt,
|
||||
DateTime? updatedAt}) {
|
||||
return new Todo(
|
||||
return Todo(
|
||||
id: id ?? this.id,
|
||||
isComplete: isComplete ?? this.isComplete,
|
||||
text: text ?? this.text,
|
||||
|
@ -187,6 +187,7 @@ class Todo extends _Todo {
|
|||
updatedAt: updatedAt ?? this.updatedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Todo &&
|
||||
other.id == id &&
|
||||
|
@ -213,11 +214,10 @@ class Todo extends _Todo {
|
|||
abstract class TodoSerializer {
|
||||
static Todo fromMap(Map map) {
|
||||
if (map['is_complete'] == null) {
|
||||
throw new FormatException(
|
||||
"Missing required field 'is_complete' on Todo.");
|
||||
throw FormatException("Missing required field 'is_complete' on Todo.");
|
||||
}
|
||||
|
||||
return new Todo(
|
||||
return Todo(
|
||||
id: map['id'] as String?,
|
||||
isComplete: map['is_complete'] as bool? ?? false,
|
||||
text: map['text'] as String?,
|
||||
|
@ -235,8 +235,7 @@ abstract class TodoSerializer {
|
|||
|
||||
static Map<String, dynamic> toMap(_Todo model) {
|
||||
if (model.isComplete == null) {
|
||||
throw new FormatException(
|
||||
"Missing required field 'is_complete' on Todo.");
|
||||
throw FormatException("Missing required field 'is_complete' on Todo.");
|
||||
}
|
||||
|
||||
return {
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'models/book.dart';
|
|||
|
||||
import 'util.dart';
|
||||
|
||||
belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
Author? jkRowling;
|
||||
|
@ -38,7 +38,7 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
group('selects', () {
|
||||
test('select all', () async {
|
||||
var query = BookQuery();
|
||||
List<Book> books = await query.get(executor);
|
||||
var books = await query.get(executor);
|
||||
expect(books, hasLength(1));
|
||||
|
||||
var book = books.first;
|
||||
|
@ -55,7 +55,7 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
test('select one', () async {
|
||||
var query = BookQuery();
|
||||
query.where!.id.equals(int.parse(deathlyHallows!.id!));
|
||||
print(query.compile(Set()));
|
||||
print(query.compile({}));
|
||||
|
||||
var bookOpt = await query.getOne(executor);
|
||||
expect(bookOpt.isPresent, true);
|
||||
|
@ -75,9 +75,9 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
var query = BookQuery()
|
||||
..where!.name.equals('Goblet of Fire')
|
||||
..orWhere((w) => w.authorId.equals(int.parse(jkRowling!.id!)));
|
||||
print(query.compile(Set()));
|
||||
print(query.compile({}));
|
||||
|
||||
List<Book> books = await query.get(executor);
|
||||
var books = await query.get(executor);
|
||||
expect(books, hasLength(1));
|
||||
|
||||
var book = books.first;
|
||||
|
@ -99,9 +99,9 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
query1
|
||||
..union(query2)
|
||||
..unionAll(query3);
|
||||
print(query1.compile(Set()));
|
||||
print(query1.compile({}));
|
||||
|
||||
List<Book> books = await query1.get(executor);
|
||||
var books = await query1.get(executor);
|
||||
expect(books, hasLength(1));
|
||||
|
||||
var book = books.first;
|
||||
|
@ -117,7 +117,7 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
|
||||
test('order by', () async {
|
||||
var query = AuthorQuery()..orderBy(AuthorFields.name, descending: true);
|
||||
List<Author> authors = await query.get(executor);
|
||||
var authors = await query.get(executor);
|
||||
expect(authors, [jkRowling, jameson]);
|
||||
});
|
||||
});
|
||||
|
@ -131,8 +131,8 @@ belongsToTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
test('delete stream', () async {
|
||||
printSeparator('Delete stream test');
|
||||
var query = BookQuery()..where!.name.equals(deathlyHallows!.name!);
|
||||
print(query.compile(Set(), preamble: 'DELETE', withFields: false));
|
||||
List<Book> books = await query.delete(executor);
|
||||
print(query.compile({}, preamble: 'DELETE', withFields: false));
|
||||
var books = await query.delete(executor);
|
||||
expect(books, hasLength(1));
|
||||
|
||||
var book = books.first;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:angel3_orm/angel3_orm.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'models/custom_expr.dart';
|
||||
|
||||
customExprTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void customExprTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
Numbers? numbersModel;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:angel3_orm/angel3_orm.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'models/unorthodox.dart';
|
||||
|
||||
edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
close ??= (_) => null;
|
||||
|
@ -81,7 +81,7 @@ edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
test('has many', () async {
|
||||
var numbas = <Numba>[];
|
||||
|
||||
for (int i = 0; i < 15; i++) {
|
||||
for (var i = 0; i < 15; i++) {
|
||||
var query = NumbaQuery()
|
||||
..values.parent = weirdJoin!.id
|
||||
..values.i = i;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:angel3_orm/angel3_orm.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'models/has_car.dart';
|
||||
|
||||
enumAndNestedTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void enumAndNestedTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
close ??= (_) => null;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:angel3_orm/angel3_orm.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'models/tree.dart';
|
||||
|
||||
hasManyTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void hasManyTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
Tree? appleTree;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:angel3_orm/angel3_orm.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'models/has_map.dart';
|
||||
|
||||
hasMapTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void hasMapTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
close ??= (_) => null;
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'package:angel3_orm/angel3_orm.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'models/leg.dart';
|
||||
|
||||
hasOneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void hasOneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
Leg? originalLeg;
|
||||
|
@ -18,7 +18,7 @@ hasOneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
tearDown(() => close!(executor));
|
||||
|
||||
test('sets to null if no child', () async {
|
||||
print(LegQuery().compile(Set()));
|
||||
print(LegQuery().compile({}));
|
||||
var query = LegQuery()..where!.id.equals(int.parse(originalLeg!.id!));
|
||||
var legOpt = await (query.getOne(executor));
|
||||
expect(legOpt.isPresent, true);
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'package:test/test.dart';
|
|||
import 'models/user.dart';
|
||||
import 'util.dart';
|
||||
|
||||
manyToManyTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void manyToManyTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
Role? canPub, canSub;
|
||||
|
|
|
@ -14,7 +14,7 @@ class _Book extends Model {
|
|||
@BelongsTo(joinType: JoinType.inner)
|
||||
_Author? author;
|
||||
|
||||
@BelongsTo(localKey: "partner_author_id", joinType: JoinType.inner)
|
||||
@BelongsTo(localKey: 'partner_author_id', joinType: JoinType.inner)
|
||||
_Author? partnerAuthor;
|
||||
|
||||
String? name;
|
||||
|
|
|
@ -8,9 +8,9 @@ part of angel_orm3.generator.models.book;
|
|||
|
||||
class BookMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('books', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('name');
|
||||
|
@ -24,24 +24,24 @@ class BookMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('books');
|
||||
}
|
||||
}
|
||||
|
||||
class AuthorMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('authors', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('name', length: 255)..defaultsTo('Tobe Osakwe');
|
||||
table.varChar('name', length: 255).defaultsTo('Tobe Osakwe');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('authors');
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ class AuthorMigration extends Migration {
|
|||
|
||||
class BookQuery extends Query<Book, BookQueryWhere> {
|
||||
BookQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = BookQueryWhere(this);
|
||||
join(_author = AuthorQuery(trampoline: trampoline, parent: this),
|
||||
|
@ -75,17 +75,17 @@ class BookQuery extends Query<Book, BookQueryWhere> {
|
|||
AuthorQuery? _partnerAuthor;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'books';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const [
|
||||
'id',
|
||||
'created_at',
|
||||
|
@ -167,14 +167,14 @@ class BookQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder name;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, authorId, partnerAuthorId, name];
|
||||
}
|
||||
}
|
||||
|
||||
class BookQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -224,7 +224,7 @@ class BookQueryValues extends MapQueryValues {
|
|||
class AuthorQuery extends Query<Author, AuthorQueryWhere> {
|
||||
AuthorQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = AuthorQueryWhere(this);
|
||||
}
|
||||
|
@ -235,17 +235,17 @@ class AuthorQuery extends Query<Author, AuthorQueryWhere> {
|
|||
AuthorQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'authors';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'name'];
|
||||
}
|
||||
|
||||
|
@ -293,14 +293,14 @@ class AuthorQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder name;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, name];
|
||||
}
|
||||
}
|
||||
|
||||
class AuthorQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -382,6 +382,7 @@ class Book extends _Book {
|
|||
name: name ?? this.name);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Book &&
|
||||
other.id == id &&
|
||||
|
@ -399,7 +400,7 @@ class Book extends _Book {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Book(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, author=$author, partnerAuthor=$partnerAuthor, name=$name)";
|
||||
return 'Book(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, author=$author, partnerAuthor=$partnerAuthor, name=$name)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -435,6 +436,7 @@ class Author extends _Author {
|
|||
name: name ?? this.name);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Author &&
|
||||
other.id == id &&
|
||||
|
@ -450,7 +452,7 @@ class Author extends _Author {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Author(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, name=$name)";
|
||||
return 'Author(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, name=$name)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -482,9 +484,9 @@ class BookSerializer extends Codec<Book, Map> {
|
|||
const BookSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const BookEncoder();
|
||||
BookEncoder get encoder => const BookEncoder();
|
||||
@override
|
||||
get decoder => const BookDecoder();
|
||||
BookDecoder get decoder => const BookDecoder();
|
||||
static Book fromMap(Map map) {
|
||||
return Book(
|
||||
id: map['id'] as String?,
|
||||
|
@ -562,9 +564,9 @@ class AuthorSerializer extends Codec<Author, Map?> {
|
|||
const AuthorSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const AuthorEncoder();
|
||||
AuthorEncoder get encoder => const AuthorEncoder();
|
||||
@override
|
||||
get decoder => const AuthorDecoder();
|
||||
AuthorDecoder get decoder => const AuthorDecoder();
|
||||
static Author fromMap(Map map) {
|
||||
return Author(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -8,9 +8,9 @@ part of angel_orm3.generator.models.car;
|
|||
|
||||
class CarMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('cars', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('make');
|
||||
|
@ -21,7 +21,7 @@ class CarMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('cars');
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ class CarMigration extends Migration {
|
|||
|
||||
class CarQuery extends Query<Car, CarQueryWhere> {
|
||||
CarQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = CarQueryWhere(this);
|
||||
}
|
||||
|
@ -43,17 +43,17 @@ class CarQuery extends Query<Car, CarQueryWhere> {
|
|||
CarQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'cars';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const [
|
||||
'id',
|
||||
'created_at',
|
||||
|
@ -121,7 +121,7 @@ class CarQueryWhere extends QueryWhere {
|
|||
final DateTimeSqlExpressionBuilder recalledAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [
|
||||
id,
|
||||
createdAt,
|
||||
|
@ -136,7 +136,7 @@ class CarQueryWhere extends QueryWhere {
|
|||
|
||||
class CarQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -242,6 +242,7 @@ class Car extends _Car {
|
|||
recalledAt: recalledAt ?? this.recalledAt);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Car &&
|
||||
other.id == id &&
|
||||
|
@ -268,7 +269,7 @@ class Car extends _Car {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Car(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, make=$make, description=$description, familyFriendly=$familyFriendly, recalledAt=$recalledAt)";
|
||||
return 'Car(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, make=$make, description=$description, familyFriendly=$familyFriendly, recalledAt=$recalledAt)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -300,9 +301,9 @@ class CarSerializer extends Codec<Car, Map> {
|
|||
const CarSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const CarEncoder();
|
||||
CarEncoder get encoder => const CarEncoder();
|
||||
@override
|
||||
get decoder => const CarDecoder();
|
||||
CarDecoder get decoder => const CarDecoder();
|
||||
static Car fromMap(Map map) {
|
||||
return Car(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -8,25 +8,25 @@ part of 'custom_expr.dart';
|
|||
|
||||
class NumbersMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('numbers', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('numbers');
|
||||
}
|
||||
}
|
||||
|
||||
class AlphabetMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('alphabets', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('value');
|
||||
|
@ -37,7 +37,7 @@ class AlphabetMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('alphabets');
|
||||
}
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ class AlphabetMigration extends Migration {
|
|||
class NumbersQuery extends Query<Numbers, NumbersQueryWhere> {
|
||||
NumbersQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
expressions['two'] = 'SELECT 2';
|
||||
_where = NumbersQueryWhere(this);
|
||||
|
@ -61,17 +61,17 @@ class NumbersQuery extends Query<Numbers, NumbersQueryWhere> {
|
|||
NumbersQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'numbers';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'two'];
|
||||
}
|
||||
|
||||
|
@ -116,14 +116,14 @@ class NumbersQueryWhere extends QueryWhere {
|
|||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt];
|
||||
}
|
||||
}
|
||||
|
||||
class NumbersQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -151,7 +151,7 @@ class NumbersQueryValues extends MapQueryValues {
|
|||
class AlphabetQuery extends Query<Alphabet, AlphabetQueryWhere> {
|
||||
AlphabetQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = AlphabetQueryWhere(this);
|
||||
leftJoin(_numbers = NumbersQuery(trampoline: trampoline, parent: this),
|
||||
|
@ -168,17 +168,17 @@ class AlphabetQuery extends Query<Alphabet, AlphabetQueryWhere> {
|
|||
NumbersQuery? _numbers;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'alphabets';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'value', 'numbers_id'];
|
||||
}
|
||||
|
||||
|
@ -239,14 +239,14 @@ class AlphabetQueryWhere extends QueryWhere {
|
|||
final NumericSqlExpressionBuilder<int> numbersId;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, value, numbersId];
|
||||
}
|
||||
}
|
||||
|
||||
class AlphabetQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -317,6 +317,7 @@ class Numbers extends _Numbers {
|
|||
two: two ?? this.two);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Numbers &&
|
||||
other.id == id &&
|
||||
|
@ -332,7 +333,7 @@ class Numbers extends _Numbers {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Numbers(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, two=$two)";
|
||||
return 'Numbers(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, two=$two)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -376,6 +377,7 @@ class Alphabet extends _Alphabet {
|
|||
numbers: numbers ?? this.numbers);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Alphabet &&
|
||||
other.id == id &&
|
||||
|
@ -392,7 +394,7 @@ class Alphabet extends _Alphabet {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Alphabet(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, value=$value, numbers=$numbers)";
|
||||
return 'Alphabet(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, value=$value, numbers=$numbers)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -424,9 +426,9 @@ class NumbersSerializer extends Codec<Numbers, Map?> {
|
|||
const NumbersSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const NumbersEncoder();
|
||||
NumbersEncoder get encoder => const NumbersEncoder();
|
||||
@override
|
||||
get decoder => const NumbersDecoder();
|
||||
NumbersDecoder get decoder => const NumbersDecoder();
|
||||
static Numbers fromMap(Map map) {
|
||||
return Numbers(
|
||||
id: map['id'] as String?,
|
||||
|
@ -488,9 +490,9 @@ class AlphabetSerializer extends Codec<Alphabet, Map> {
|
|||
const AlphabetSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const AlphabetEncoder();
|
||||
AlphabetEncoder get encoder => const AlphabetEncoder();
|
||||
@override
|
||||
get decoder => const AlphabetDecoder();
|
||||
AlphabetDecoder get decoder => const AlphabetDecoder();
|
||||
static Alphabet fromMap(Map map) {
|
||||
return Alphabet(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -8,21 +8,21 @@ part of 'email_indexed.dart';
|
|||
|
||||
class RoleMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('roles', (table) {
|
||||
table.declare('role', ColumnType('varchar'))..primaryKey();
|
||||
table.declare('role', ColumnType('varchar')).primaryKey();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('roles', cascade: true);
|
||||
}
|
||||
}
|
||||
|
||||
class RoleUserMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('role_users', (table) {
|
||||
table
|
||||
.declare('role_role', ColumnType('varchar'))
|
||||
|
@ -34,23 +34,23 @@ class RoleUserMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('role_users');
|
||||
}
|
||||
}
|
||||
|
||||
class UserMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('users', (table) {
|
||||
table.varChar('email')..primaryKey();
|
||||
table.varChar('email').primaryKey();
|
||||
table.varChar('name');
|
||||
table.varChar('password');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('users', cascade: true);
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ class UserMigration extends Migration {
|
|||
|
||||
class RoleQuery extends Query<Role, RoleQueryWhere> {
|
||||
RoleQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = RoleQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -78,17 +78,17 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
late RoleQueryWhere _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'roles';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['role'];
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<Role>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<Role>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.role == model.role);
|
||||
|
@ -146,7 +146,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<Role>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<Role>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.role == model.role);
|
||||
|
@ -164,7 +164,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<Role>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<Role>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.role == model.role);
|
||||
|
@ -189,14 +189,14 @@ class RoleQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder role;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [role];
|
||||
}
|
||||
}
|
||||
|
||||
class RoleQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -213,7 +213,7 @@ class RoleQueryValues extends MapQueryValues {
|
|||
class RoleUserQuery extends Query<RoleUser, RoleUserQueryWhere> {
|
||||
RoleUserQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = RoleUserQueryWhere(this);
|
||||
leftJoin(_role = RoleQuery(trampoline: trampoline, parent: this),
|
||||
|
@ -235,17 +235,17 @@ class RoleUserQuery extends Query<RoleUser, RoleUserQueryWhere> {
|
|||
UserQuery? _user;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'role_users';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['role_role', 'user_email'];
|
||||
}
|
||||
|
||||
|
@ -303,14 +303,14 @@ class RoleUserQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder userEmail;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [roleRole, userEmail];
|
||||
}
|
||||
}
|
||||
|
||||
class RoleUserQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -336,7 +336,7 @@ class RoleUserQueryValues extends MapQueryValues {
|
|||
|
||||
class UserQuery extends Query<User, UserQueryWhere> {
|
||||
UserQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = UserQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -353,17 +353,17 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
UserQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'users';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['email', 'name', 'password'];
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<User>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<User>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.email == model.email);
|
||||
|
@ -428,7 +428,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<User>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<User>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.email == model.email);
|
||||
|
@ -446,7 +446,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<User>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<User>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.email == model.email);
|
||||
|
@ -477,14 +477,14 @@ class UserQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder password;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [email, name, password];
|
||||
}
|
||||
}
|
||||
|
||||
class UserQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -528,6 +528,7 @@ class Role implements _Role {
|
|||
return Role(role: role ?? this.role, users: users);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Role &&
|
||||
other.role == role &&
|
||||
|
@ -542,7 +543,7 @@ class Role implements _Role {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Role(role=$role, users=$users)";
|
||||
return 'Role(role=$role, users=$users)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -564,6 +565,7 @@ class RoleUser implements _RoleUser {
|
|||
return RoleUser(role: role ?? this.role, user: user ?? this.user);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _RoleUser && other.role == role && other.user == user;
|
||||
}
|
||||
|
@ -575,7 +577,7 @@ class RoleUser implements _RoleUser {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "RoleUser(role=$role, user=$user)";
|
||||
return 'RoleUser(role=$role, user=$user)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -608,6 +610,7 @@ class User implements _User {
|
|||
roles: roles ?? []);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _User &&
|
||||
other.email == email &&
|
||||
|
@ -624,7 +627,7 @@ class User implements _User {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "User(email=$email, name=$name, password=$password, roles=$roles)";
|
||||
return 'User(email=$email, name=$name, password=$password, roles=$roles)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -656,9 +659,9 @@ class RoleSerializer extends Codec<Role, Map?> {
|
|||
const RoleSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const RoleEncoder();
|
||||
RoleEncoder get encoder => const RoleEncoder();
|
||||
@override
|
||||
get decoder => const RoleDecoder();
|
||||
RoleDecoder get decoder => const RoleDecoder();
|
||||
static Role fromMap(Map map) {
|
||||
return Role(
|
||||
role: map['role'] as String?,
|
||||
|
@ -704,9 +707,9 @@ class RoleUserSerializer extends Codec<RoleUser, Map> {
|
|||
const RoleUserSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const RoleUserEncoder();
|
||||
RoleUserEncoder get encoder => const RoleUserEncoder();
|
||||
@override
|
||||
get decoder => const RoleUserDecoder();
|
||||
RoleUserDecoder get decoder => const RoleUserDecoder();
|
||||
static RoleUser fromMap(Map map) {
|
||||
return RoleUser(
|
||||
role: map['role'] != null
|
||||
|
@ -753,9 +756,9 @@ class UserSerializer extends Codec<User, Map?> {
|
|||
const UserSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const UserEncoder();
|
||||
UserEncoder get encoder => const UserEncoder();
|
||||
@override
|
||||
get decoder => const UserDecoder();
|
||||
UserDecoder get decoder => const UserDecoder();
|
||||
static User fromMap(Map map) {
|
||||
return User(
|
||||
email: map['email'] as String?,
|
||||
|
|
|
@ -8,9 +8,9 @@ part of 'has_car.dart';
|
|||
|
||||
class HasCarMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('has_cars', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.integer('type');
|
||||
|
@ -18,7 +18,7 @@ class HasCarMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('has_cars');
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,7 @@ class HasCarMigration extends Migration {
|
|||
class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
|
||||
HasCarQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = HasCarQueryWhere(this);
|
||||
}
|
||||
|
@ -41,17 +41,17 @@ class HasCarQuery extends Query<HasCar, HasCarQueryWhere> {
|
|||
HasCarQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'has_cars';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'type'];
|
||||
}
|
||||
|
||||
|
@ -100,14 +100,14 @@ class HasCarQueryWhere extends QueryWhere {
|
|||
final EnumSqlExpressionBuilder<CarType?> type;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, type];
|
||||
}
|
||||
}
|
||||
|
||||
class HasCarQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -170,6 +170,7 @@ class HasCar extends _HasCar {
|
|||
type: type ?? this.type);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _HasCar &&
|
||||
other.id == id &&
|
||||
|
@ -185,7 +186,7 @@ class HasCar extends _HasCar {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "HasCar(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, type=$type)";
|
||||
return 'HasCar(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, type=$type)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -217,9 +218,9 @@ class HasCarSerializer extends Codec<HasCar, Map> {
|
|||
const HasCarSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const HasCarEncoder();
|
||||
HasCarEncoder get encoder => const HasCarEncoder();
|
||||
@override
|
||||
get decoder => const HasCarDecoder();
|
||||
HasCarDecoder get decoder => const HasCarDecoder();
|
||||
static HasCar fromMap(Map map) {
|
||||
if (map['type'] == null) {
|
||||
throw FormatException("Missing required field 'type' on HasCar.");
|
||||
|
|
|
@ -8,7 +8,7 @@ part of 'has_map.dart';
|
|||
|
||||
class HasMapMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('has_maps', (table) {
|
||||
table.declare('value', ColumnType('jsonb'));
|
||||
table.declare('list', ColumnType('jsonb'));
|
||||
|
@ -16,7 +16,7 @@ class HasMapMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('has_maps');
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ class HasMapMigration extends Migration {
|
|||
class HasMapQuery extends Query<HasMap, HasMapQueryWhere> {
|
||||
HasMapQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = HasMapQueryWhere(this);
|
||||
}
|
||||
|
@ -39,17 +39,17 @@ class HasMapQuery extends Query<HasMap, HasMapQueryWhere> {
|
|||
HasMapQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'has_maps';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['value', 'list'];
|
||||
}
|
||||
|
||||
|
@ -90,14 +90,14 @@ class HasMapQueryWhere extends QueryWhere {
|
|||
final ListSqlExpressionBuilder list;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [value, list];
|
||||
}
|
||||
}
|
||||
|
||||
class HasMapQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {'list': 'jsonb'};
|
||||
}
|
||||
|
||||
|
@ -136,6 +136,7 @@ class HasMap implements _HasMap {
|
|||
return HasMap(value: value, list: list);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _HasMap &&
|
||||
MapEquality<dynamic, dynamic>(
|
||||
|
@ -183,9 +184,9 @@ class HasMapSerializer extends Codec<HasMap, Map> {
|
|||
const HasMapSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const HasMapEncoder();
|
||||
HasMapEncoder get encoder => const HasMapEncoder();
|
||||
@override
|
||||
get decoder => const HasMapDecoder();
|
||||
HasMapDecoder get decoder => const HasMapDecoder();
|
||||
static HasMap fromMap(Map map) {
|
||||
return HasMap(
|
||||
value: map['value'] is Map
|
||||
|
|
|
@ -8,9 +8,9 @@ part of angel3_orm_generator.test.models.leg;
|
|||
|
||||
class LegMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('legs', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('name');
|
||||
|
@ -18,16 +18,16 @@ class LegMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('legs', cascade: true);
|
||||
}
|
||||
}
|
||||
|
||||
class FootMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('feet', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.integer('leg_id');
|
||||
|
@ -36,7 +36,7 @@ class FootMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('feet');
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class FootMigration extends Migration {
|
|||
|
||||
class LegQuery extends Query<Leg, LegQueryWhere> {
|
||||
LegQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = LegQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -70,17 +70,17 @@ class LegQuery extends Query<Leg, LegQueryWhere> {
|
|||
FootQuery? _foot;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'legs';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'name'];
|
||||
}
|
||||
|
||||
|
@ -138,14 +138,14 @@ class LegQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder name;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, name];
|
||||
}
|
||||
}
|
||||
|
||||
class LegQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -178,7 +178,7 @@ class LegQueryValues extends MapQueryValues {
|
|||
|
||||
class FootQuery extends Query<Foot, FootQueryWhere> {
|
||||
FootQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = FootQueryWhere(this);
|
||||
}
|
||||
|
@ -189,17 +189,17 @@ class FootQuery extends Query<Foot, FootQueryWhere> {
|
|||
FootQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {'n_toes': 'text'};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'feet';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'leg_id', 'n_toes'];
|
||||
}
|
||||
|
||||
|
@ -251,14 +251,14 @@ class FootQueryWhere extends QueryWhere {
|
|||
final NumericSqlExpressionBuilder<double> nToes;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, legId, nToes];
|
||||
}
|
||||
}
|
||||
|
||||
class FootQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {'n_toes': 'decimal'};
|
||||
}
|
||||
|
||||
|
@ -335,6 +335,7 @@ class Leg extends _Leg {
|
|||
name: name ?? this.name);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Leg &&
|
||||
other.id == id &&
|
||||
|
@ -351,7 +352,7 @@ class Leg extends _Leg {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Leg(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, foot=$foot, name=$name)";
|
||||
return 'Leg(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, foot=$foot, name=$name)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -395,6 +396,7 @@ class Foot extends _Foot {
|
|||
nToes: nToes ?? this.nToes);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Foot &&
|
||||
other.id == id &&
|
||||
|
@ -411,7 +413,7 @@ class Foot extends _Foot {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Foot(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, legId=$legId, nToes=$nToes)";
|
||||
return 'Foot(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, legId=$legId, nToes=$nToes)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -443,9 +445,9 @@ class LegSerializer extends Codec<Leg, Map> {
|
|||
const LegSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const LegEncoder();
|
||||
LegEncoder get encoder => const LegEncoder();
|
||||
@override
|
||||
get decoder => const LegDecoder();
|
||||
LegDecoder get decoder => const LegDecoder();
|
||||
static Leg fromMap(Map map) {
|
||||
return Leg(
|
||||
id: map['id'] as String?,
|
||||
|
@ -516,9 +518,9 @@ class FootSerializer extends Codec<Foot, Map?> {
|
|||
const FootSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FootEncoder();
|
||||
FootEncoder get encoder => const FootEncoder();
|
||||
@override
|
||||
get decoder => const FootDecoder();
|
||||
FootDecoder get decoder => const FootDecoder();
|
||||
static Foot fromMap(Map map) {
|
||||
return Foot(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -8,9 +8,9 @@ part of angel3_orm_generator.test.models.order;
|
|||
|
||||
class OrderMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('orders', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.integer('employee_id');
|
||||
|
@ -23,23 +23,23 @@ class OrderMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('orders');
|
||||
}
|
||||
}
|
||||
|
||||
class CustomerMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('customers', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('customers');
|
||||
}
|
||||
}
|
||||
|
@ -50,7 +50,7 @@ class CustomerMigration extends Migration {
|
|||
|
||||
class OrderQuery extends Query<Order, OrderQueryWhere> {
|
||||
OrderQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = OrderQueryWhere(this);
|
||||
leftJoin(_customer = CustomerQuery(trampoline: trampoline, parent: this),
|
||||
|
@ -67,17 +67,17 @@ class OrderQuery extends Query<Order, OrderQueryWhere> {
|
|||
CustomerQuery? _customer;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'orders';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const [
|
||||
'id',
|
||||
'created_at',
|
||||
|
@ -154,7 +154,7 @@ class OrderQueryWhere extends QueryWhere {
|
|||
final NumericSqlExpressionBuilder<int> shipperId;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [
|
||||
id,
|
||||
createdAt,
|
||||
|
@ -169,7 +169,7 @@ class OrderQueryWhere extends QueryWhere {
|
|||
|
||||
class OrderQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -223,7 +223,7 @@ class OrderQueryValues extends MapQueryValues {
|
|||
class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
|
||||
CustomerQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = CustomerQueryWhere(this);
|
||||
}
|
||||
|
@ -234,17 +234,17 @@ class CustomerQuery extends Query<Customer, CustomerQueryWhere> {
|
|||
CustomerQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'customers';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at'];
|
||||
}
|
||||
|
||||
|
@ -288,14 +288,14 @@ class CustomerQueryWhere extends QueryWhere {
|
|||
final DateTimeSqlExpressionBuilder updatedAt;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt];
|
||||
}
|
||||
}
|
||||
|
||||
class CustomerQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -377,6 +377,7 @@ class Order extends _Order {
|
|||
shipperId: shipperId ?? this.shipperId);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Order &&
|
||||
other.id == id &&
|
||||
|
@ -396,7 +397,7 @@ class Order extends _Order {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Order(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, customer=$customer, employeeId=$employeeId, orderDate=$orderDate, shipperId=$shipperId)";
|
||||
return 'Order(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, customer=$customer, employeeId=$employeeId, orderDate=$orderDate, shipperId=$shipperId)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -427,6 +428,7 @@ class Customer extends _Customer {
|
|||
updatedAt: updatedAt ?? this.updatedAt);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Customer &&
|
||||
other.id == id &&
|
||||
|
@ -441,7 +443,7 @@ class Customer extends _Customer {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Customer(id=$id, createdAt=$createdAt, updatedAt=$updatedAt)";
|
||||
return 'Customer(id=$id, createdAt=$createdAt, updatedAt=$updatedAt)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -473,9 +475,9 @@ class OrderSerializer extends Codec<Order, Map> {
|
|||
const OrderSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const OrderEncoder();
|
||||
OrderEncoder get encoder => const OrderEncoder();
|
||||
@override
|
||||
get decoder => const OrderDecoder();
|
||||
OrderDecoder get decoder => const OrderDecoder();
|
||||
static Order fromMap(Map map) {
|
||||
return Order(
|
||||
id: map['id'] as String?,
|
||||
|
@ -560,9 +562,9 @@ class CustomerSerializer extends Codec<Customer, Map?> {
|
|||
const CustomerSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const CustomerEncoder();
|
||||
CustomerEncoder get encoder => const CustomerEncoder();
|
||||
@override
|
||||
get decoder => const CustomerDecoder();
|
||||
CustomerDecoder get decoder => const CustomerDecoder();
|
||||
static Customer fromMap(Map map) {
|
||||
return Customer(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -8,9 +8,9 @@ part of angel3_orm_generator.test.models.tree;
|
|||
|
||||
class TreeMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('trees', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.declare('rings', ColumnType('smallint'));
|
||||
|
@ -18,16 +18,16 @@ class TreeMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('trees', cascade: true);
|
||||
}
|
||||
}
|
||||
|
||||
class FruitMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('fruits', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.integer('tree_id');
|
||||
|
@ -36,7 +36,7 @@ class FruitMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('fruits');
|
||||
}
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ class FruitMigration extends Migration {
|
|||
|
||||
class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
||||
TreeQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = TreeQueryWhere(this);
|
||||
leftJoin(_fruits = FruitQuery(trampoline: trampoline, parent: this), 'id',
|
||||
|
@ -70,17 +70,17 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|||
FruitQuery? _fruits;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'trees';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'rings'];
|
||||
}
|
||||
|
||||
|
@ -122,7 +122,7 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<Tree>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<Tree>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -141,7 +141,7 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<Tree>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<Tree>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -160,7 +160,7 @@ class TreeQuery extends Query<Tree, TreeQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<Tree>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<Tree>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -195,14 +195,14 @@ class TreeQueryWhere extends QueryWhere {
|
|||
final NumericSqlExpressionBuilder<int> rings;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, rings];
|
||||
}
|
||||
}
|
||||
|
||||
class TreeQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -235,7 +235,7 @@ class TreeQueryValues extends MapQueryValues {
|
|||
|
||||
class FruitQuery extends Query<Fruit, FruitQueryWhere> {
|
||||
FruitQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = FruitQueryWhere(this);
|
||||
}
|
||||
|
@ -246,17 +246,17 @@ class FruitQuery extends Query<Fruit, FruitQueryWhere> {
|
|||
FruitQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'fruits';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'tree_id', 'common_name'];
|
||||
}
|
||||
|
||||
|
@ -308,14 +308,14 @@ class FruitQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder commonName;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, treeId, commonName];
|
||||
}
|
||||
}
|
||||
|
||||
class FruitQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -364,7 +364,7 @@ class Tree extends _Tree {
|
|||
this.updatedAt,
|
||||
this.rings,
|
||||
List<_Fruit> fruits = const []})
|
||||
: this.fruits = List.unmodifiable(fruits);
|
||||
: fruits = List.unmodifiable(fruits);
|
||||
|
||||
/// A unique identifier corresponding to this item.
|
||||
@override
|
||||
|
@ -398,6 +398,7 @@ class Tree extends _Tree {
|
|||
fruits: fruits);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Tree &&
|
||||
other.id == id &&
|
||||
|
@ -415,7 +416,7 @@ class Tree extends _Tree {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Tree(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, rings=$rings, fruits=$fruits)";
|
||||
return 'Tree(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, rings=$rings, fruits=$fruits)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -460,6 +461,7 @@ class Fruit extends _Fruit {
|
|||
commonName: commonName ?? this.commonName);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Fruit &&
|
||||
other.id == id &&
|
||||
|
@ -476,7 +478,7 @@ class Fruit extends _Fruit {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Fruit(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, treeId=$treeId, commonName=$commonName)";
|
||||
return 'Fruit(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, treeId=$treeId, commonName=$commonName)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -508,9 +510,9 @@ class TreeSerializer extends Codec<Tree, Map> {
|
|||
const TreeSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const TreeEncoder();
|
||||
TreeEncoder get encoder => const TreeEncoder();
|
||||
@override
|
||||
get decoder => const TreeDecoder();
|
||||
TreeDecoder get decoder => const TreeDecoder();
|
||||
static Tree fromMap(Map map) {
|
||||
return Tree(
|
||||
id: map['id'] as String?,
|
||||
|
@ -582,9 +584,9 @@ class FruitSerializer extends Codec<Fruit, Map> {
|
|||
const FruitSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FruitEncoder();
|
||||
FruitEncoder get encoder => const FruitEncoder();
|
||||
@override
|
||||
get decoder => const FruitDecoder();
|
||||
FruitDecoder get decoder => const FruitDecoder();
|
||||
static Fruit fromMap(Map map) {
|
||||
return Fruit(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -48,6 +48,7 @@ class _Numba implements Comparable<_Numba> {
|
|||
|
||||
int? parent;
|
||||
|
||||
@override
|
||||
int compareTo(_Numba other) => i!.compareTo(other.i!);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,23 +8,23 @@ part of 'unorthodox.dart';
|
|||
|
||||
class UnorthodoxMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('unorthodoxes', (table) {
|
||||
table.varChar('name');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('unorthodoxes');
|
||||
}
|
||||
}
|
||||
|
||||
class WeirdJoinMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('weird_joins', (table) {
|
||||
table.integer('id')..primaryKey();
|
||||
table.integer('id').primaryKey();
|
||||
table
|
||||
.declare('join_name', ColumnType('varchar'))
|
||||
.references('unorthodoxes', 'name');
|
||||
|
@ -32,16 +32,16 @@ class WeirdJoinMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('weird_joins', cascade: true);
|
||||
}
|
||||
}
|
||||
|
||||
class SongMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('songs', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.integer('weird_join_id');
|
||||
|
@ -50,43 +50,43 @@ class SongMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('songs');
|
||||
}
|
||||
}
|
||||
|
||||
class NumbaMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('numbas', (table) {
|
||||
table.integer('i')..primaryKey();
|
||||
table.integer('i').primaryKey();
|
||||
table.integer('parent');
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('numbas');
|
||||
}
|
||||
}
|
||||
|
||||
class FooMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('foos', (table) {
|
||||
table.varChar('bar')..primaryKey();
|
||||
table.varChar('bar').primaryKey();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('foos', cascade: true);
|
||||
}
|
||||
}
|
||||
|
||||
class FooPivotMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('foo_pivots', (table) {
|
||||
table
|
||||
.declare('weird_join_id', ColumnType('int'))
|
||||
|
@ -96,7 +96,7 @@ class FooPivotMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('foo_pivots');
|
||||
}
|
||||
}
|
||||
|
@ -108,7 +108,7 @@ class FooPivotMigration extends Migration {
|
|||
class UnorthodoxQuery extends Query<Unorthodox, UnorthodoxQueryWhere> {
|
||||
UnorthodoxQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = UnorthodoxQueryWhere(this);
|
||||
}
|
||||
|
@ -119,17 +119,17 @@ class UnorthodoxQuery extends Query<Unorthodox, UnorthodoxQueryWhere> {
|
|||
UnorthodoxQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'unorthodoxes';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['name'];
|
||||
}
|
||||
|
||||
|
@ -164,14 +164,14 @@ class UnorthodoxQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder name;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [name];
|
||||
}
|
||||
}
|
||||
|
||||
class UnorthodoxQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -188,7 +188,7 @@ class UnorthodoxQueryValues extends MapQueryValues {
|
|||
class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
|
||||
WeirdJoinQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = WeirdJoinQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -230,17 +230,17 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
|
|||
NumbaQuery? _numbas;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'weird_joins';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'join_name'];
|
||||
}
|
||||
|
||||
|
@ -310,7 +310,7 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<WeirdJoin>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<WeirdJoin>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -330,7 +330,7 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<WeirdJoin>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<WeirdJoin>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -350,7 +350,7 @@ class WeirdJoinQuery extends Query<WeirdJoin, WeirdJoinQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<WeirdJoin>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<WeirdJoin>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -380,14 +380,14 @@ class WeirdJoinQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder joinName;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, joinName];
|
||||
}
|
||||
}
|
||||
|
||||
class WeirdJoinQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -411,7 +411,7 @@ class WeirdJoinQueryValues extends MapQueryValues {
|
|||
|
||||
class SongQuery extends Query<Song, SongQueryWhere> {
|
||||
SongQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = SongQueryWhere(this);
|
||||
}
|
||||
|
@ -422,17 +422,17 @@ class SongQuery extends Query<Song, SongQueryWhere> {
|
|||
SongQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'songs';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'weird_join_id', 'title'];
|
||||
}
|
||||
|
||||
|
@ -484,14 +484,14 @@ class SongQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder title;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, weirdJoinId, title];
|
||||
}
|
||||
}
|
||||
|
||||
class SongQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -530,7 +530,7 @@ class SongQueryValues extends MapQueryValues {
|
|||
|
||||
class NumbaQuery extends Query<Numba, NumbaQueryWhere> {
|
||||
NumbaQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = NumbaQueryWhere(this);
|
||||
}
|
||||
|
@ -541,17 +541,17 @@ class NumbaQuery extends Query<Numba, NumbaQueryWhere> {
|
|||
NumbaQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'numbas';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['i', 'parent'];
|
||||
}
|
||||
|
||||
|
@ -589,14 +589,14 @@ class NumbaQueryWhere extends QueryWhere {
|
|||
final NumericSqlExpressionBuilder<int> parent;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [i, parent];
|
||||
}
|
||||
}
|
||||
|
||||
class NumbaQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -618,7 +618,7 @@ class NumbaQueryValues extends MapQueryValues {
|
|||
|
||||
class FooQuery extends Query<Foo, FooQueryWhere> {
|
||||
FooQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = FooQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -635,17 +635,17 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
|
|||
FooQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'foos';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['bar'];
|
||||
}
|
||||
|
||||
|
@ -685,7 +685,7 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<Foo>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<Foo>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.bar == model.bar);
|
||||
|
@ -704,7 +704,7 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<Foo>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<Foo>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.bar == model.bar);
|
||||
|
@ -723,7 +723,7 @@ class FooQuery extends Query<Foo, FooQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<Foo>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<Foo>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.bar == model.bar);
|
||||
|
@ -749,14 +749,14 @@ class FooQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder bar;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [bar];
|
||||
}
|
||||
}
|
||||
|
||||
class FooQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -773,7 +773,7 @@ class FooQueryValues extends MapQueryValues {
|
|||
class FooPivotQuery extends Query<FooPivot, FooPivotQueryWhere> {
|
||||
FooPivotQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = FooPivotQueryWhere(this);
|
||||
leftJoin(_weirdJoin = WeirdJoinQuery(trampoline: trampoline, parent: this),
|
||||
|
@ -794,17 +794,17 @@ class FooPivotQuery extends Query<FooPivot, FooPivotQueryWhere> {
|
|||
FooQuery? _foo;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'foo_pivots';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['weird_join_id', 'foo_bar'];
|
||||
}
|
||||
|
||||
|
@ -862,14 +862,14 @@ class FooPivotQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder fooBar;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [weirdJoinId, fooBar];
|
||||
}
|
||||
}
|
||||
|
||||
class FooPivotQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -908,6 +908,7 @@ class Unorthodox implements _Unorthodox {
|
|||
return Unorthodox(name: name ?? this.name);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Unorthodox && other.name == name;
|
||||
}
|
||||
|
@ -919,7 +920,7 @@ class Unorthodox implements _Unorthodox {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Unorthodox(name=$name)";
|
||||
return 'Unorthodox(name=$name)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -961,6 +962,7 @@ class WeirdJoin implements _WeirdJoin {
|
|||
foos: foos ?? this.foos);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _WeirdJoin &&
|
||||
other.id == id &&
|
||||
|
@ -978,7 +980,7 @@ class WeirdJoin implements _WeirdJoin {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "WeirdJoin(id=$id, unorthodox=$unorthodox, song=$song, numbas=$numbas, foos=$foos)";
|
||||
return 'WeirdJoin(id=$id, unorthodox=$unorthodox, song=$song, numbas=$numbas, foos=$foos)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -1022,6 +1024,7 @@ class Song extends _Song {
|
|||
title: title ?? this.title);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Song &&
|
||||
other.id == id &&
|
||||
|
@ -1038,7 +1041,7 @@ class Song extends _Song {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Song(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, weirdJoinId=$weirdJoinId, title=$title)";
|
||||
return 'Song(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, weirdJoinId=$weirdJoinId, title=$title)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -1060,6 +1063,7 @@ class Numba extends _Numba {
|
|||
return Numba(i: i ?? this.i, parent: parent ?? this.parent);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Numba && other.i == i && other.parent == parent;
|
||||
}
|
||||
|
@ -1071,7 +1075,7 @@ class Numba extends _Numba {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Numba(i=$i, parent=$parent)";
|
||||
return 'Numba(i=$i, parent=$parent)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -1093,6 +1097,7 @@ class Foo implements _Foo {
|
|||
return Foo(bar: bar ?? this.bar, weirdJoins: weirdJoins ?? this.weirdJoins);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Foo &&
|
||||
other.bar == bar &&
|
||||
|
@ -1107,7 +1112,7 @@ class Foo implements _Foo {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Foo(bar=$bar, weirdJoins=$weirdJoins)";
|
||||
return 'Foo(bar=$bar, weirdJoins=$weirdJoins)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -1130,6 +1135,7 @@ class FooPivot implements _FooPivot {
|
|||
weirdJoin: weirdJoin ?? this.weirdJoin, foo: foo ?? this.foo);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _FooPivot &&
|
||||
other.weirdJoin == weirdJoin &&
|
||||
|
@ -1143,7 +1149,7 @@ class FooPivot implements _FooPivot {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "FooPivot(weirdJoin=$weirdJoin, foo=$foo)";
|
||||
return 'FooPivot(weirdJoin=$weirdJoin, foo=$foo)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -1175,9 +1181,9 @@ class UnorthodoxSerializer extends Codec<Unorthodox, Map?> {
|
|||
const UnorthodoxSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const UnorthodoxEncoder();
|
||||
UnorthodoxEncoder get encoder => const UnorthodoxEncoder();
|
||||
@override
|
||||
get decoder => const UnorthodoxDecoder();
|
||||
UnorthodoxDecoder get decoder => const UnorthodoxDecoder();
|
||||
static Unorthodox fromMap(Map map) {
|
||||
return Unorthodox(name: map['name'] as String?);
|
||||
}
|
||||
|
@ -1216,9 +1222,9 @@ class WeirdJoinSerializer extends Codec<WeirdJoin, Map?> {
|
|||
const WeirdJoinSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const WeirdJoinEncoder();
|
||||
WeirdJoinEncoder get encoder => const WeirdJoinEncoder();
|
||||
@override
|
||||
get decoder => const WeirdJoinDecoder();
|
||||
WeirdJoinDecoder get decoder => const WeirdJoinDecoder();
|
||||
static WeirdJoin fromMap(Map map) {
|
||||
return WeirdJoin(
|
||||
id: map['id'] as int?,
|
||||
|
@ -1292,9 +1298,9 @@ class SongSerializer extends Codec<Song, Map?> {
|
|||
const SongSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const SongEncoder();
|
||||
SongEncoder get encoder => const SongEncoder();
|
||||
@override
|
||||
get decoder => const SongDecoder();
|
||||
SongDecoder get decoder => const SongDecoder();
|
||||
static Song fromMap(Map map) {
|
||||
return Song(
|
||||
id: map['id'] as String?,
|
||||
|
@ -1366,9 +1372,9 @@ class NumbaSerializer extends Codec<Numba, Map?> {
|
|||
const NumbaSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const NumbaEncoder();
|
||||
NumbaEncoder get encoder => const NumbaEncoder();
|
||||
@override
|
||||
get decoder => const NumbaDecoder();
|
||||
NumbaDecoder get decoder => const NumbaDecoder();
|
||||
static Numba fromMap(Map map) {
|
||||
return Numba(i: map['i'] as int?, parent: map['parent'] as int?);
|
||||
}
|
||||
|
@ -1409,9 +1415,9 @@ class FooSerializer extends Codec<Foo, Map?> {
|
|||
const FooSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FooEncoder();
|
||||
FooEncoder get encoder => const FooEncoder();
|
||||
@override
|
||||
get decoder => const FooDecoder();
|
||||
FooDecoder get decoder => const FooDecoder();
|
||||
static Foo fromMap(Map map) {
|
||||
return Foo(
|
||||
bar: map['bar'] as String?,
|
||||
|
@ -1462,9 +1468,9 @@ class FooPivotSerializer extends Codec<FooPivot, Map> {
|
|||
const FooPivotSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const FooPivotEncoder();
|
||||
FooPivotEncoder get encoder => const FooPivotEncoder();
|
||||
@override
|
||||
get decoder => const FooPivotDecoder();
|
||||
FooPivotDecoder get decoder => const FooPivotDecoder();
|
||||
static FooPivot fromMap(Map map) {
|
||||
return FooPivot(
|
||||
weirdJoin: map['weird_join'] != null
|
||||
|
|
|
@ -8,9 +8,9 @@ part of angel3_orm_generator.test.models.user;
|
|||
|
||||
class UserMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('users', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('username');
|
||||
|
@ -20,14 +20,14 @@ class UserMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('users', cascade: true);
|
||||
}
|
||||
}
|
||||
|
||||
class RoleUserMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('role_users', (table) {
|
||||
table.declare('role_id', ColumnType('serial')).references('roles', 'id');
|
||||
table.declare('user_id', ColumnType('serial')).references('users', 'id');
|
||||
|
@ -35,16 +35,16 @@ class RoleUserMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('role_users');
|
||||
}
|
||||
}
|
||||
|
||||
class RoleMigration extends Migration {
|
||||
@override
|
||||
up(Schema schema) {
|
||||
void up(Schema schema) {
|
||||
schema.create('roles', (table) {
|
||||
table.serial('id')..primaryKey();
|
||||
table.serial('id').primaryKey();
|
||||
table.timeStamp('created_at');
|
||||
table.timeStamp('updated_at');
|
||||
table.varChar('name');
|
||||
|
@ -52,7 +52,7 @@ class RoleMigration extends Migration {
|
|||
}
|
||||
|
||||
@override
|
||||
down(Schema schema) {
|
||||
void down(Schema schema) {
|
||||
schema.drop('roles', cascade: true);
|
||||
}
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ class RoleMigration extends Migration {
|
|||
|
||||
class UserQuery extends Query<User, UserQueryWhere> {
|
||||
UserQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = UserQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -80,17 +80,17 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
UserQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'users';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const [
|
||||
'id',
|
||||
'created_at',
|
||||
|
@ -143,7 +143,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<User>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<User>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -161,7 +161,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<User>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<User>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -179,7 +179,7 @@ class UserQuery extends Query<User, UserQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<User>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<User>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -219,14 +219,14 @@ class UserQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder email;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, username, password, email];
|
||||
}
|
||||
}
|
||||
|
||||
class UserQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -272,7 +272,7 @@ class UserQueryValues extends MapQueryValues {
|
|||
class RoleUserQuery extends Query<RoleUser, RoleUserQueryWhere> {
|
||||
RoleUserQuery({Query? parent, Set<String>? trampoline})
|
||||
: super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = RoleUserQueryWhere(this);
|
||||
leftJoin(_role = RoleQuery(trampoline: trampoline, parent: this), 'role_id',
|
||||
|
@ -302,17 +302,17 @@ class RoleUserQuery extends Query<RoleUser, RoleUserQueryWhere> {
|
|||
UserQuery? _user;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'role_users';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['role_id', 'user_id'];
|
||||
}
|
||||
|
||||
|
@ -370,14 +370,14 @@ class RoleUserQueryWhere extends QueryWhere {
|
|||
final NumericSqlExpressionBuilder<int> userId;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [roleId, userId];
|
||||
}
|
||||
}
|
||||
|
||||
class RoleUserQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -403,7 +403,7 @@ class RoleUserQueryValues extends MapQueryValues {
|
|||
|
||||
class RoleQuery extends Query<Role, RoleQueryWhere> {
|
||||
RoleQuery({Query? parent, Set<String>? trampoline}) : super(parent: parent) {
|
||||
trampoline ??= Set();
|
||||
trampoline ??= <String>{};
|
||||
trampoline.add(tableName);
|
||||
_where = RoleQueryWhere(this);
|
||||
leftJoin(
|
||||
|
@ -427,17 +427,17 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
RoleQueryWhere? _where;
|
||||
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
@override
|
||||
get tableName {
|
||||
String get tableName {
|
||||
return 'roles';
|
||||
}
|
||||
|
||||
@override
|
||||
get fields {
|
||||
List<String> get fields {
|
||||
return const ['id', 'created_at', 'updated_at', 'name'];
|
||||
}
|
||||
|
||||
|
@ -481,7 +481,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
get(QueryExecutor executor) {
|
||||
Future<List<Role>> get(QueryExecutor executor) {
|
||||
return super.get(executor).then((result) {
|
||||
return result.fold<List<Role>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -499,7 +499,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
update(QueryExecutor executor) {
|
||||
Future<List<Role>> update(QueryExecutor executor) {
|
||||
return super.update(executor).then((result) {
|
||||
return result.fold<List<Role>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -517,7 +517,7 @@ class RoleQuery extends Query<Role, RoleQueryWhere> {
|
|||
}
|
||||
|
||||
@override
|
||||
delete(QueryExecutor executor) {
|
||||
Future<List<Role>> delete(QueryExecutor executor) {
|
||||
return super.delete(executor).then((result) {
|
||||
return result.fold<List<Role>>([], (out, model) {
|
||||
var idx = out.indexWhere((m) => m.id == model.id);
|
||||
|
@ -551,14 +551,14 @@ class RoleQueryWhere extends QueryWhere {
|
|||
final StringSqlExpressionBuilder name;
|
||||
|
||||
@override
|
||||
get expressionBuilders {
|
||||
List<SqlExpressionBuilder> get expressionBuilders {
|
||||
return [id, createdAt, updatedAt, name];
|
||||
}
|
||||
}
|
||||
|
||||
class RoleQueryValues extends MapQueryValues {
|
||||
@override
|
||||
get casts {
|
||||
Map<String, String> get casts {
|
||||
return {};
|
||||
}
|
||||
|
||||
|
@ -603,7 +603,7 @@ class User extends _User {
|
|||
this.password,
|
||||
this.email,
|
||||
List<_Role> roles = const []})
|
||||
: this.roles = List.unmodifiable(roles);
|
||||
: roles = List.unmodifiable(roles);
|
||||
|
||||
/// A unique identifier corresponding to this item.
|
||||
@override
|
||||
|
@ -647,6 +647,7 @@ class User extends _User {
|
|||
roles: roles);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _User &&
|
||||
other.id == id &&
|
||||
|
@ -667,7 +668,7 @@ class User extends _User {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "User(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, username=$username, password=$password, email=$email, roles=$roles)";
|
||||
return 'User(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, username=$username, password=$password, email=$email, roles=$roles)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -689,6 +690,7 @@ class RoleUser implements _RoleUser {
|
|||
return RoleUser(role: role ?? this.role, user: user ?? this.user);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _RoleUser && other.role == role && other.user == user;
|
||||
}
|
||||
|
@ -700,7 +702,7 @@ class RoleUser implements _RoleUser {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "RoleUser(role=$role, user=$user)";
|
||||
return 'RoleUser(role=$role, user=$user)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -712,7 +714,7 @@ class RoleUser implements _RoleUser {
|
|||
class Role extends _Role {
|
||||
Role(
|
||||
{this.id, this.createdAt, this.updatedAt, this.name, List<_User?>? users})
|
||||
: this.users = List.unmodifiable(users ?? []);
|
||||
: users = List.unmodifiable(users ?? []);
|
||||
|
||||
/// A unique identifier corresponding to this item.
|
||||
@override
|
||||
|
@ -746,6 +748,7 @@ class Role extends _Role {
|
|||
users: users ?? this.users);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Role &&
|
||||
other.id == id &&
|
||||
|
@ -763,7 +766,7 @@ class Role extends _Role {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Role(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, name=$name, users=$users)";
|
||||
return 'Role(id=$id, createdAt=$createdAt, updatedAt=$updatedAt, name=$name, users=$users)';
|
||||
}
|
||||
|
||||
Map<String, dynamic>? toJson() {
|
||||
|
@ -795,9 +798,9 @@ class UserSerializer extends Codec<User, Map?> {
|
|||
const UserSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const UserEncoder();
|
||||
UserEncoder get encoder => const UserEncoder();
|
||||
@override
|
||||
get decoder => const UserDecoder();
|
||||
UserDecoder get decoder => const UserDecoder();
|
||||
static User fromMap(Map map) {
|
||||
return User(
|
||||
id: map['id'] as String?,
|
||||
|
@ -882,9 +885,9 @@ class RoleUserSerializer extends Codec<RoleUser, Map> {
|
|||
const RoleUserSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const RoleUserEncoder();
|
||||
RoleUserEncoder get encoder => const RoleUserEncoder();
|
||||
@override
|
||||
get decoder => const RoleUserDecoder();
|
||||
RoleUserDecoder get decoder => const RoleUserDecoder();
|
||||
static RoleUser fromMap(Map map) {
|
||||
return RoleUser(
|
||||
role: map['role'] != null
|
||||
|
@ -931,9 +934,9 @@ class RoleSerializer extends Codec<Role, Map?> {
|
|||
const RoleSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const RoleEncoder();
|
||||
RoleEncoder get encoder => const RoleEncoder();
|
||||
@override
|
||||
get decoder => const RoleDecoder();
|
||||
RoleDecoder get decoder => const RoleDecoder();
|
||||
static Role fromMap(Map map) {
|
||||
return Role(
|
||||
id: map['id'] as String?,
|
||||
|
|
|
@ -5,7 +5,7 @@ import 'models/car.dart';
|
|||
|
||||
final DateTime y2k = DateTime.utc(2000, 1, 1);
|
||||
|
||||
standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
void standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
close ??= (_) => null;
|
||||
test('to where', () {
|
||||
|
@ -52,7 +52,7 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
|
||||
group('selects', () {
|
||||
test('select all', () async {
|
||||
List<Car> cars = await CarQuery().get(executor);
|
||||
var cars = await CarQuery().get(executor);
|
||||
expect(cars, []);
|
||||
});
|
||||
|
||||
|
@ -70,7 +70,7 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
|
||||
test('where clause is applied', () async {
|
||||
var query = CarQuery()..where!.familyFriendly.isTrue;
|
||||
List<Car> cars = await query.get(executor);
|
||||
var cars = await query.get(executor);
|
||||
expect(cars, isEmpty);
|
||||
|
||||
var sportsCars = CarQuery()..where!.familyFriendly.isFalse;
|
||||
|
@ -88,8 +88,8 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
var query1 = CarQuery()..where?.make.like('%Fer%');
|
||||
var query2 = CarQuery()..where?.familyFriendly.isTrue;
|
||||
var query3 = CarQuery()..where?.description.equals('Submarine');
|
||||
Union<Car> union = query1.union(query2).unionAll(query3);
|
||||
print(union.compile(Set()));
|
||||
var union = query1.union(query2).unionAll(query3);
|
||||
print(union.compile({}));
|
||||
var cars = await union.get(executor);
|
||||
expect(cars, hasLength(1));
|
||||
});
|
||||
|
@ -100,15 +100,15 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
..orWhere((where) => where
|
||||
..familyFriendly.isTrue
|
||||
..make.equals('Honda'));
|
||||
print(query.compile(Set()));
|
||||
List<Car> cars = await query.get(executor);
|
||||
print(query.compile({}));
|
||||
var cars = await query.get(executor);
|
||||
expect(cars, hasLength(1));
|
||||
});
|
||||
|
||||
test('limit obeyed', () async {
|
||||
var query = CarQuery()..limit(0);
|
||||
print(query.compile(Set()));
|
||||
List<Car> cars = await query.get(executor);
|
||||
print(query.compile({}));
|
||||
var cars = await query.get(executor);
|
||||
expect(cars, isEmpty);
|
||||
});
|
||||
|
||||
|
@ -132,7 +132,7 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
expect(car.toJson(), ferrari!.toJson());
|
||||
});
|
||||
|
||||
List<Car> cars = await CarQuery().get(executor);
|
||||
var cars = await CarQuery().get(executor);
|
||||
expect(cars, isEmpty);
|
||||
});
|
||||
|
||||
|
@ -140,9 +140,9 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
var query = CarQuery()
|
||||
..where!.make.equals('Ferrari東')
|
||||
..orWhere((w) => w.familyFriendly.isTrue);
|
||||
print(query.compile(Set(), preamble: 'DELETE FROM "cars"'));
|
||||
print(query.compile({}, preamble: 'DELETE FROM "cars"'));
|
||||
|
||||
List<Car> cars = await query.delete(executor);
|
||||
var cars = await query.delete(executor);
|
||||
expect(cars, hasLength(1));
|
||||
expect(cars.first.toJson(), ferrari!.toJson());
|
||||
});
|
||||
|
@ -151,7 +151,7 @@ standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
var query = CarQuery()
|
||||
..where!.id.equals(int.parse(ferrari!.id!))
|
||||
..values.make = 'Hyundai';
|
||||
List<Car> cars = await query.update(executor);
|
||||
var cars = await query.update(executor);
|
||||
expect(cars, hasLength(1));
|
||||
expect(cars.first.make, 'Hyundai');
|
||||
});
|
||||
|
|
|
@ -3,10 +3,10 @@ import 'package:io/ansi.dart';
|
|||
|
||||
void printSeparator(String title) {
|
||||
var b = StringBuffer('===' + title.toUpperCase());
|
||||
for (int i = b.length; i < stdout.terminalColumns - 3; i++) {
|
||||
for (var i = b.length; i < stdout.terminalColumns - 3; i++) {
|
||||
b.write('=');
|
||||
}
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (var i = 0; i < 3; i++) {
|
||||
print(magenta.wrap(b.toString()));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,7 +56,7 @@ HookedServiceEventListener belongsTo(Pattern servicePath,
|
|||
'query': {foreignKey ?? 'id': id}
|
||||
});
|
||||
|
||||
if (indexed == null || indexed is! List || indexed.isNotEmpty != true) {
|
||||
if (indexed is! List || indexed.isNotEmpty != true) {
|
||||
await _assignForeignObject(null, obj);
|
||||
} else {
|
||||
var child = indexed.first;
|
||||
|
|
|
@ -56,7 +56,7 @@ HookedServiceEventListener belongsToMany(Pattern servicePath,
|
|||
'query': {foreignKey ?? 'id': id}
|
||||
});
|
||||
|
||||
if (indexed == null || indexed is! List || indexed.isNotEmpty != true) {
|
||||
if (indexed is! List || indexed.isNotEmpty != true) {
|
||||
await _assignForeignObject(null, obj);
|
||||
} else {
|
||||
var child = indexed is Iterable ? indexed.toList() : [indexed];
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:angel_framework/angel_framework.dart';
|
||||
import 'package:angel_relations/angel_relations.dart' as relations;
|
||||
import 'package:angel_seeder/angel_seeder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'common.dart';
|
||||
|
|
|
@ -11,7 +11,7 @@ class CustomMapService extends Service {
|
|||
|
||||
var r = items;
|
||||
|
||||
if (params != null && params['query'] is Map) {
|
||||
if (params['query'] is Map) {
|
||||
var query = params['query'] as Map;
|
||||
|
||||
for (var key in query.keys) {
|
||||
|
@ -28,7 +28,7 @@ class CustomMapService extends Service {
|
|||
@override
|
||||
Future<Map> read(id, [Map? params]) async {
|
||||
return tailor(_items, params).firstWhere((m) => m['id'] == id,
|
||||
orElse: (() => throw AngelHttpException.notFound()) as Map<dynamic, dynamic> Function()?);
|
||||
orElse: (() => throw AngelHttpException.notFound()));
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
import 'package:angel_framework/angel_framework.dart';
|
||||
import 'package:angel_relations/angel_relations.dart' as relations;
|
||||
import 'package:angel_seeder/angel_seeder.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'common.dart';
|
||||
|
@ -36,7 +35,7 @@ void main() {
|
|||
|
||||
expect(authors, allOf(isList, isNotEmpty));
|
||||
|
||||
for (Map author in authors.whereType<Map>()) {
|
||||
for (var author in authors.whereType<Map>()) {
|
||||
expect(author.keys, contains('book'));
|
||||
|
||||
var book = author['book'] as Map;
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import 'dart:io';
|
||||
import 'package:rethinkdb_dart/rethinkdb_dart.dart';
|
||||
|
||||
main() async {
|
||||
var r = new Rethinkdb();
|
||||
r.connect().then((conn) {
|
||||
void main() async {
|
||||
var r = Rethinkdb();
|
||||
await r.connect().then((conn) {
|
||||
r.tableCreate('todos').run(conn);
|
||||
print('Done');
|
||||
exit(0);
|
||||
|
|
|
@ -2,7 +2,7 @@ class Todo {
|
|||
String title;
|
||||
bool completed;
|
||||
|
||||
Todo({this.title, this.completed: false});
|
||||
Todo({this.title, this.completed = false});
|
||||
|
||||
Map toJson() {
|
||||
return {'title': title, 'completed': completed == true};
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'package:rethinkdb_dart/rethinkdb_dart.dart';
|
|||
import 'package:test/test.dart';
|
||||
import 'common.dart';
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
Angel app;
|
||||
TestClient client;
|
||||
Rethinkdb r;
|
||||
|
|
|
@ -23,7 +23,7 @@ abstract class BrowserRouter<T> extends Router<T> {
|
|||
: _PushStateRouter<T>(listen: listen);
|
||||
}
|
||||
|
||||
BrowserRouter._() : super();
|
||||
//BrowserRouter._() : super();
|
||||
|
||||
void _goTo(String path);
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ class MiddlewarePipeline<T> {
|
|||
}
|
||||
|
||||
MiddlewarePipeline(Iterable<RoutingResult<T>> routingResults)
|
||||
: this.routingResults = routingResults.toList();
|
||||
: routingResults = routingResults.toList();
|
||||
}
|
||||
|
||||
/// Iterates through a [MiddlewarePipeline].
|
||||
|
|
|
@ -182,7 +182,7 @@ void main() {
|
|||
});
|
||||
|
||||
group('404', () {
|
||||
expect404(r) => r.then((res) {
|
||||
dynamic expect404(r) => r.then((res) {
|
||||
print('Response (${res.statusCode}): ${res.body}');
|
||||
expect(res.statusCode, equals(404));
|
||||
});
|
||||
|
|
|
@ -23,9 +23,7 @@ class ServiceRateLimiter<Id> extends RateLimiter<Id> {
|
|||
var id = await getId(req, res);
|
||||
try {
|
||||
var data = await service.read(id);
|
||||
if (data != null) {
|
||||
return RateLimitingWindow.fromJson(data);
|
||||
}
|
||||
return RateLimitingWindow.fromJson(data);
|
||||
} catch (e) {
|
||||
if (e is AngelHttpException) {
|
||||
if (e.statusCode == 404) {
|
||||
|
|
|
@ -55,7 +55,7 @@ class Todo extends Model {
|
|||
final String? text;
|
||||
final bool? completed;
|
||||
|
||||
Todo({String? id, this.text, this.completed: false}) {
|
||||
Todo({String? id, this.text, this.completed = false}) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ library angel_serialize.test.models.book;
|
|||
import 'package:angel3_model/angel3_model.dart';
|
||||
import 'package:angel3_serialize/angel3_serialize.dart';
|
||||
import 'package:collection/collection.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
part 'book.g.dart';
|
||||
|
||||
@Serializable(
|
||||
|
|
|
@ -20,7 +20,7 @@ class Book extends _Book {
|
|||
this.pageCount,
|
||||
List<double>? notModels,
|
||||
this.camelCaseString})
|
||||
: this.notModels = List.unmodifiable(notModels ?? []);
|
||||
: notModels = List.unmodifiable(notModels ?? []);
|
||||
|
||||
/// A unique identifier corresponding to this item.
|
||||
@override
|
||||
|
@ -75,6 +75,7 @@ class Book extends _Book {
|
|||
camelCaseString: camelCaseString ?? this.camelCaseString);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Book &&
|
||||
other.id == id &&
|
||||
|
@ -126,7 +127,7 @@ class Author extends _Author {
|
|||
this.newestBook,
|
||||
this.secret,
|
||||
this.obscured})
|
||||
: this.books = List.unmodifiable(books ?? []);
|
||||
: books = List.unmodifiable(books ?? []);
|
||||
|
||||
/// A unique identifier corresponding to this item.
|
||||
@override
|
||||
|
@ -181,6 +182,7 @@ class Author extends _Author {
|
|||
obscured: obscured ?? this.obscured);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Author &&
|
||||
other.id == id &&
|
||||
|
@ -253,6 +255,7 @@ class Library extends _Library {
|
|||
collection: collection ?? this.collection);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Library &&
|
||||
other.id == id &&
|
||||
|
@ -328,6 +331,7 @@ class Bookmark extends _Bookmark {
|
|||
comment: comment ?? this.comment);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Bookmark &&
|
||||
other.id == id &&
|
||||
|
|
|
@ -21,6 +21,7 @@ class GamepadButton implements _GamepadButton {
|
|||
name: name ?? this.name, radius: radius ?? this.radius);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _GamepadButton &&
|
||||
other.name == name &&
|
||||
|
@ -34,7 +35,7 @@ class GamepadButton implements _GamepadButton {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "GamepadButton(name=$name, radius=$radius)";
|
||||
return 'GamepadButton(name=$name, radius=$radius)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -45,8 +46,8 @@ class GamepadButton implements _GamepadButton {
|
|||
@generatedSerializable
|
||||
class Gamepad extends _Gamepad {
|
||||
Gamepad({List<_GamepadButton>? buttons, Map<String, dynamic>? dynamicMap})
|
||||
: this.buttons = List.unmodifiable(buttons ?? []),
|
||||
this.dynamicMap = Map.unmodifiable(dynamicMap ?? {});
|
||||
: buttons = List.unmodifiable(buttons ?? []),
|
||||
dynamicMap = Map.unmodifiable(dynamicMap ?? {});
|
||||
|
||||
@override
|
||||
List<_GamepadButton>? buttons;
|
||||
|
@ -61,6 +62,7 @@ class Gamepad extends _Gamepad {
|
|||
dynamicMap: dynamicMap ?? this.dynamicMap);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Gamepad &&
|
||||
ListEquality<_GamepadButton>(DefaultEquality<_GamepadButton>())
|
||||
|
@ -77,7 +79,7 @@ class Gamepad extends _Gamepad {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Gamepad(buttons=$buttons, dynamicMap=$dynamicMap)";
|
||||
return 'Gamepad(buttons=$buttons, dynamicMap=$dynamicMap)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -110,9 +112,9 @@ class GamepadButtonSerializer extends Codec<GamepadButton, Map> {
|
|||
const GamepadButtonSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const GamepadButtonEncoder();
|
||||
GamepadButtonEncoder get encoder => const GamepadButtonEncoder();
|
||||
@override
|
||||
get decoder => const GamepadButtonDecoder();
|
||||
GamepadButtonDecoder get decoder => const GamepadButtonDecoder();
|
||||
static GamepadButton fromMap(Map map) {
|
||||
return GamepadButton(
|
||||
name: map['name'] as String?, radius: map['radius'] as int?);
|
||||
|
@ -151,9 +153,9 @@ class GamepadSerializer extends Codec<Gamepad, Map> {
|
|||
const GamepadSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const GamepadEncoder();
|
||||
GamepadEncoder get encoder => const GamepadEncoder();
|
||||
@override
|
||||
get decoder => const GamepadDecoder();
|
||||
GamepadDecoder get decoder => const GamepadDecoder();
|
||||
static Gamepad fromMap(Map map) {
|
||||
return Gamepad(
|
||||
buttons: map['buttons'] is Iterable
|
||||
|
|
|
@ -20,6 +20,7 @@ class Goat implements _Goat {
|
|||
return Goat(integer: integer ?? this.integer, list: list ?? this.list);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Goat &&
|
||||
other.integer == integer &&
|
||||
|
@ -33,7 +34,7 @@ class Goat implements _Goat {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Goat(integer=$integer, list=$list)";
|
||||
return 'Goat(integer=$integer, list=$list)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -65,9 +66,9 @@ class GoatSerializer extends Codec<Goat, Map> {
|
|||
const GoatSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const GoatEncoder();
|
||||
GoatEncoder get encoder => const GoatEncoder();
|
||||
@override
|
||||
get decoder => const GoatDecoder();
|
||||
GoatDecoder get decoder => const GoatDecoder();
|
||||
static Goat fromMap(Map map) {
|
||||
return Goat(
|
||||
integer: map['integer'] as int? ?? 34,
|
||||
|
|
|
@ -17,6 +17,7 @@ class HasMap implements _HasMap {
|
|||
return HasMap(value: value ?? this.value);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _HasMap &&
|
||||
MapEquality<dynamic, dynamic>(
|
||||
|
@ -31,7 +32,7 @@ class HasMap implements _HasMap {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "HasMap(value=$value)";
|
||||
return 'HasMap(value=$value)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -63,9 +64,9 @@ class HasMapSerializer extends Codec<HasMap, Map> {
|
|||
const HasMapSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const HasMapEncoder();
|
||||
HasMapEncoder get encoder => const HasMapEncoder();
|
||||
@override
|
||||
get decoder => const HasMapDecoder();
|
||||
HasMapDecoder get decoder => const HasMapDecoder();
|
||||
static HasMap fromMap(Map map) {
|
||||
if (map['value'] == null) {
|
||||
throw FormatException("Missing required field 'value' on HasMap.");
|
||||
|
|
|
@ -20,6 +20,7 @@ class Animal extends _Animal {
|
|||
return Animal(genus: genus ?? this.genus, species: species ?? this.species);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Animal && other.genus == genus && other.species == species;
|
||||
}
|
||||
|
@ -31,7 +32,7 @@ class Animal extends _Animal {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Animal(genus=$genus, species=$species)";
|
||||
return 'Animal(genus=$genus, species=$species)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -59,6 +60,7 @@ class Bird extends _Bird {
|
|||
isSparrow: isSparrow ?? this.isSparrow);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _Bird &&
|
||||
other.genus == genus &&
|
||||
|
@ -73,7 +75,7 @@ class Bird extends _Bird {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "Bird(genus=$genus, species=$species, isSparrow=$isSparrow)";
|
||||
return 'Bird(genus=$genus, species=$species, isSparrow=$isSparrow)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -105,9 +107,9 @@ class AnimalSerializer extends Codec<Animal, Map> {
|
|||
const AnimalSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const AnimalEncoder();
|
||||
AnimalEncoder get encoder => const AnimalEncoder();
|
||||
@override
|
||||
get decoder => const AnimalDecoder();
|
||||
AnimalDecoder get decoder => const AnimalDecoder();
|
||||
static Animal fromMap(Map map) {
|
||||
if (map['genus'] == null) {
|
||||
throw FormatException("Missing required field 'genus' on Animal.");
|
||||
|
@ -162,9 +164,9 @@ class BirdSerializer extends Codec<Bird, Map> {
|
|||
const BirdSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const BirdEncoder();
|
||||
BirdEncoder get encoder => const BirdEncoder();
|
||||
@override
|
||||
get decoder => const BirdDecoder();
|
||||
BirdDecoder get decoder => const BirdDecoder();
|
||||
static Bird fromMap(Map map) {
|
||||
if (map['genus'] == null) {
|
||||
throw FormatException("Missing required field 'genus' on Bird.");
|
||||
|
|
|
@ -27,6 +27,7 @@ class WithEnum implements _WithEnum {
|
|||
imageBytes: imageBytes ?? this.imageBytes);
|
||||
}
|
||||
|
||||
@override
|
||||
bool operator ==(other) {
|
||||
return other is _WithEnum &&
|
||||
other.type == type &&
|
||||
|
@ -42,7 +43,7 @@ class WithEnum implements _WithEnum {
|
|||
|
||||
@override
|
||||
String toString() {
|
||||
return "WithEnum(type=$type, finalList=$finalList, imageBytes=$imageBytes)";
|
||||
return 'WithEnum(type=$type, finalList=$finalList, imageBytes=$imageBytes)';
|
||||
}
|
||||
|
||||
Map<String, dynamic> toJson() {
|
||||
|
@ -74,9 +75,9 @@ class WithEnumSerializer extends Codec<WithEnum, Map> {
|
|||
const WithEnumSerializer();
|
||||
|
||||
@override
|
||||
get encoder => const WithEnumEncoder();
|
||||
WithEnumEncoder get encoder => const WithEnumEncoder();
|
||||
@override
|
||||
get decoder => const WithEnumDecoder();
|
||||
WithEnumDecoder get decoder => const WithEnumDecoder();
|
||||
static WithEnum fromMap(Map map) {
|
||||
return WithEnum(
|
||||
type: map['type'] is WithEnumType
|
||||
|
|
|
@ -6,7 +6,7 @@ import 'package:logging/logging.dart';
|
|||
import 'package:pretty_logging/pretty_logging.dart';
|
||||
import 'package:shelf_static/shelf_static.dart';
|
||||
|
||||
main() async {
|
||||
void main() async {
|
||||
Logger.root
|
||||
..level = Level.ALL
|
||||
..onRecord.listen(prettyLog);
|
||||
|
|
|
@ -19,8 +19,8 @@ RequestHandler embedShelf(shelf.Handler handler,
|
|||
handlerPath: handlerPath, context: context);
|
||||
try {
|
||||
var result = await handler(shelfRequest);
|
||||
if (result is! shelf.Response && result != null) return result;
|
||||
if (result == null && throwOnNullResponse == true) {
|
||||
if (result is! shelf.Response) return result;
|
||||
if (throwOnNullResponse == true) {
|
||||
throw AngelHttpException('Internal Server Error');
|
||||
}
|
||||
await mergeShelfResponse(result, res);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import 'package:angel3_symbol_table/angel3_symbol_table.dart';
|
||||
|
||||
void main(List<String> args) {
|
||||
var mySymbolTable = SymbolTable<int>();
|
||||
//var mySymbolTable = SymbolTable<int>();
|
||||
var doubles =
|
||||
SymbolTable<double>(values: {'hydrogen': 1.0, 'avogadro': 6.022e23});
|
||||
|
||||
|
@ -17,10 +17,10 @@ void main(List<String> args) {
|
|||
doubles.remove('two');
|
||||
|
||||
// Find a symbol, either in this symbol table or an ancestor.
|
||||
var symbol1 = doubles.resolve('one');
|
||||
//var symbol1 = doubles.resolve('one');
|
||||
|
||||
// Find OR create a symbol.
|
||||
var symbol2 = doubles.resolveOrCreate('one');
|
||||
var symbol3 = doubles.resolveOrCreate('one', value: 1.0);
|
||||
var symbol4 = doubles.resolveOrCreate('one', value: 1.0, constant: true);
|
||||
//var symbol2 = doubles.resolveOrCreate('one');
|
||||
//var symbol3 = doubles.resolveOrCreate('one', value: 1.0);
|
||||
//var symbol4 = doubles.resolveOrCreate('one', value: 1.0, constant: true);
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ final Validator todoSchema = Validator({
|
|||
'completed': false
|
||||
});
|
||||
|
||||
main() {
|
||||
void main() {
|
||||
test('custom error message', () {
|
||||
var result = emailSchema.check({'to': 2});
|
||||
|
||||
|
|
|
@ -75,6 +75,7 @@ Future<void> runBenchmarks(Iterable<AngelBenchmark> benchmarks,
|
|||
exit(0);
|
||||
}
|
||||
|
||||
/*
|
||||
void _httpIsolate(AngelBenchmark benchmark) {
|
||||
Future(() async {
|
||||
var raw = await HttpServer.bind(InternetAddress.loopbackIPv4, testPort,
|
||||
|
@ -82,6 +83,7 @@ void _httpIsolate(AngelBenchmark benchmark) {
|
|||
raw.listen((r) => benchmark.rawHandler(r, r.response));
|
||||
});
|
||||
}
|
||||
*/
|
||||
|
||||
void _angelIsolate(Tuple2<AngelBenchmark, String> args) {
|
||||
Future(() async {
|
||||
|
|
|
@ -7,7 +7,7 @@ import 'package:angel_framework/angel_framework.dart';
|
|||
import 'package:mock_request/mock_request.dart';
|
||||
import 'wings_socket.dart';
|
||||
|
||||
enum _ParseState { method, url, headerField, headerValue, body }
|
||||
//enum _ParseState { method, url, headerField, headerValue, body }
|
||||
|
||||
final RegExp _straySlashes = RegExp(r'(^/+)|(/+$)');
|
||||
|
||||
|
|
|
@ -57,9 +57,7 @@ class WingsResponseContext extends ResponseContext<int?> {
|
|||
}
|
||||
}
|
||||
|
||||
if (contentType != null) {
|
||||
outHeaders['content-type'] = contentType.toString();
|
||||
}
|
||||
outHeaders['content-type'] = contentType.toString();
|
||||
|
||||
if (encoders.isNotEmpty && correspondingRequest != null) {
|
||||
if (_allowedEncodings != null) {
|
||||
|
|
Loading…
Reference in a new issue