Merge branch 'fix-bug/mysql8' into release/5.0.0
This commit is contained in:
commit
35bf04b168
71 changed files with 572 additions and 309 deletions
|
@ -43,7 +43,7 @@ class Controller {
|
|||
|
||||
var name = await applyRoutes(app, app.container!.reflector);
|
||||
app.controllers[name] = this;
|
||||
return null;
|
||||
//return null;
|
||||
}
|
||||
|
||||
/// Applies the routes from this [Controller] to some [router].
|
||||
|
|
|
@ -76,7 +76,9 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
/// Closes any open [StreamController]s on this instance. **Internal use only**.
|
||||
@override
|
||||
Future close() {
|
||||
_ctrl.forEach((c) => c.close());
|
||||
for (var c in _ctrl) {
|
||||
c.close();
|
||||
}
|
||||
beforeIndexed._close();
|
||||
beforeRead._close();
|
||||
beforeCreated._close();
|
||||
|
@ -144,8 +146,8 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
});
|
||||
|
||||
@override
|
||||
void addRoutes([Service? s]) {
|
||||
super.addRoutes(s ?? inner);
|
||||
void addRoutes([Service? service]) {
|
||||
super.addRoutes(service ?? inner);
|
||||
}
|
||||
|
||||
/// Runs the [listener] before every service method specified.
|
||||
|
@ -274,162 +276,162 @@ class HookedService<Id, Data, T extends Service<Id, Data>>
|
|||
}
|
||||
|
||||
@override
|
||||
Future<List<Data>> index([Map<String, dynamic>? _params]) {
|
||||
var params = _stripReq(_params);
|
||||
Future<List<Data>> index([Map<String, dynamic>? params]) {
|
||||
var localParams = _stripReq(params);
|
||||
return beforeIndexed
|
||||
._emit(HookedServiceEvent(false, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.indexed,
|
||||
params: params))
|
||||
._emit(HookedServiceEvent(false, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.indexed,
|
||||
params: localParams))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return afterIndexed
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.indexed,
|
||||
params: params, result: before.result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.indexed,
|
||||
params: localParams, result: before.result))
|
||||
.then((after) => after.result as List<Data>);
|
||||
}
|
||||
|
||||
return inner.index(params).then((result) {
|
||||
return inner.index(localParams).then((result) {
|
||||
return afterIndexed
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.indexed,
|
||||
params: params, result: result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.indexed,
|
||||
params: localParams, result: result))
|
||||
.then((after) => after.result as List<Data>);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Data> read(Id id, [Map<String, dynamic>? _params]) {
|
||||
var params = _stripReq(_params);
|
||||
Future<Data> read(Id id, [Map<String, dynamic>? params]) {
|
||||
var localParams = _stripReq(params);
|
||||
return beforeRead
|
||||
._emit(HookedServiceEvent(false, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.read,
|
||||
id: id, params: params))
|
||||
._emit(HookedServiceEvent(false, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.read,
|
||||
id: id, params: localParams))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return afterRead
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.read,
|
||||
id: id, params: params, result: before.result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.read,
|
||||
id: id, params: localParams, result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.read(id, params).then((result) {
|
||||
return inner.read(id, localParams).then((result) {
|
||||
return afterRead
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.read,
|
||||
id: id, params: params, result: result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.read,
|
||||
id: id, params: localParams, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Data> create(Data data, [Map<String, dynamic>? _params]) {
|
||||
var params = _stripReq(_params);
|
||||
Future<Data> create(Data data, [Map<String, dynamic>? params]) {
|
||||
var localParams = _stripReq(params);
|
||||
return beforeCreated
|
||||
._emit(HookedServiceEvent(false, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
data: data, params: params))
|
||||
._emit(HookedServiceEvent(false, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.created,
|
||||
data: data, params: localParams))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return afterCreated
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
data: before.data, params: params, result: before.result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.created,
|
||||
data: before.data, params: localParams, result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.create(before.data!, params).then((result) {
|
||||
return inner.create(before.data!, localParams).then((result) {
|
||||
return afterCreated
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
data: before.data, params: params, result: result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.created,
|
||||
data: before.data, params: localParams, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Data> modify(Id id, Data data, [Map<String, dynamic>? _params]) {
|
||||
var params = _stripReq(_params);
|
||||
Future<Data> modify(Id id, Data data, [Map<String, dynamic>? params]) {
|
||||
var localParams = _stripReq(params);
|
||||
return beforeModified
|
||||
._emit(HookedServiceEvent(false, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.modified,
|
||||
id: id, data: data, params: params))
|
||||
._emit(HookedServiceEvent(false, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.modified,
|
||||
id: id, data: data, params: localParams))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return afterModified
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.modified,
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.modified,
|
||||
id: id,
|
||||
data: before.data,
|
||||
params: params,
|
||||
params: localParams,
|
||||
result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.modify(id, before.data!, params).then((result) {
|
||||
return inner.modify(id, before.data!, localParams).then((result) {
|
||||
return afterModified
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.created,
|
||||
id: id, data: before.data, params: params, result: result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.created,
|
||||
id: id, data: before.data, params: localParams, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Data> update(Id id, Data data, [Map<String, dynamic>? _params]) {
|
||||
var params = _stripReq(_params);
|
||||
Future<Data> update(Id id, Data data, [Map<String, dynamic>? params]) {
|
||||
var localParams = _stripReq(params);
|
||||
return beforeUpdated
|
||||
._emit(HookedServiceEvent(false, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: data, params: params))
|
||||
._emit(HookedServiceEvent(false, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: data, params: localParams))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return afterUpdated
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.updated,
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.updated,
|
||||
id: id,
|
||||
data: before.data,
|
||||
params: params,
|
||||
params: localParams,
|
||||
result: before.result))
|
||||
.then((after) => after.result as Data);
|
||||
}
|
||||
|
||||
return inner.update(id, before.data!, params).then((result) {
|
||||
return inner.update(id, before.data!, localParams).then((result) {
|
||||
return afterUpdated
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: before.data, params: params, result: result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.updated,
|
||||
id: id, data: before.data, params: localParams, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<Data> remove(Id id, [Map<String, dynamic>? _params]) {
|
||||
var params = _stripReq(_params);
|
||||
Future<Data> remove(Id id, [Map<String, dynamic>? params]) {
|
||||
var localParams = _stripReq(params);
|
||||
return beforeRemoved
|
||||
._emit(HookedServiceEvent(false, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: params))
|
||||
._emit(HookedServiceEvent(false, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: localParams))
|
||||
.then((before) {
|
||||
if (before._canceled) {
|
||||
return afterRemoved
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: params, result: before.result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: localParams, result: before.result))
|
||||
.then((after) => after.result) as Data;
|
||||
}
|
||||
|
||||
return inner.remove(id, params).then((result) {
|
||||
return inner.remove(id, localParams).then((result) {
|
||||
return afterRemoved
|
||||
._emit(HookedServiceEvent(true, _getRequest(_params),
|
||||
_getResponse(_params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: params, result: result))
|
||||
._emit(HookedServiceEvent(true, _getRequest(params),
|
||||
_getResponse(params), inner, HookedServiceEvent.removed,
|
||||
id: id, params: localParams, result: result))
|
||||
.then((after) => after.result as Data);
|
||||
});
|
||||
});
|
||||
|
@ -520,7 +522,7 @@ class HookedServiceEvent<Id, Data, T extends Service<Id, Data>> {
|
|||
Map<String, dynamic>? _params;
|
||||
final RequestContext? _request;
|
||||
final ResponseContext? _response;
|
||||
var result;
|
||||
dynamic result;
|
||||
|
||||
String get eventName => _eventName;
|
||||
|
||||
|
@ -557,7 +559,9 @@ class HookedServiceEventDispatcher<Id, Data, T extends Service<Id, Data>> {
|
|||
final List<HookedServiceEventListener<Id, Data, T>> listeners = [];
|
||||
|
||||
void _close() {
|
||||
_ctrl.forEach((c) => c.close());
|
||||
for (var c in _ctrl) {
|
||||
c.close();
|
||||
}
|
||||
listeners.clear();
|
||||
}
|
||||
|
||||
|
|
|
@ -26,7 +26,7 @@ RequestHandler ioc(Function handler, {Iterable<String> optional = const []}) {
|
|||
Future resolveInjection(requirement, InjectionRequest injection,
|
||||
RequestContext req, ResponseContext res, bool throwOnUnresolved,
|
||||
[Container? container]) async {
|
||||
var propFromApp;
|
||||
dynamic propFromApp;
|
||||
container ??= req.container ?? res.app!.container;
|
||||
|
||||
if (requirement == RequestContext) {
|
||||
|
|
|
@ -58,7 +58,9 @@ class MapService extends Service<String?, Map<String, dynamic>> {
|
|||
for (var key in query!.keys) {
|
||||
if (!item.containsKey(key)) {
|
||||
return false;
|
||||
} else if (item[key] != query[key]) return false;
|
||||
} else if (item[key] != query[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -77,11 +79,11 @@ class MapService extends Service<String?, Map<String, dynamic>> {
|
|||
@override
|
||||
Future<Map<String, dynamic>> create(Map<String, dynamic> data,
|
||||
[Map<String, dynamic>? params]) {
|
||||
if (data is! Map) {
|
||||
throw AngelHttpException.badRequest(
|
||||
message:
|
||||
'MapService does not support `create` with ${data.runtimeType}.');
|
||||
}
|
||||
//if (data is! Map) {
|
||||
// throw AngelHttpException.badRequest(
|
||||
// message:
|
||||
// 'MapService does not support `create` with ${data.runtimeType}.');
|
||||
//}
|
||||
var now = DateTime.now().toIso8601String();
|
||||
var result = Map<String, dynamic>.from(data);
|
||||
|
||||
|
@ -98,11 +100,11 @@ class MapService extends Service<String?, Map<String, dynamic>> {
|
|||
@override
|
||||
Future<Map<String, dynamic>> modify(String? id, Map<String, dynamic> data,
|
||||
[Map<String, dynamic>? params]) {
|
||||
if (data is! Map) {
|
||||
throw AngelHttpException.badRequest(
|
||||
message:
|
||||
'MapService does not support `modify` with ${data.runtimeType}.');
|
||||
}
|
||||
//if (data is! Map) {
|
||||
// throw AngelHttpException.badRequest(
|
||||
// message:
|
||||
// 'MapService does not support `modify` with ${data.runtimeType}.');
|
||||
//}
|
||||
if (!items.any(_matchesId(id))) return create(data, params);
|
||||
|
||||
return read(id).then((item) {
|
||||
|
@ -121,11 +123,11 @@ class MapService extends Service<String?, Map<String, dynamic>> {
|
|||
@override
|
||||
Future<Map<String, dynamic>> update(String? id, Map<String, dynamic> data,
|
||||
[Map<String, dynamic>? params]) {
|
||||
if (data is! Map) {
|
||||
throw AngelHttpException.badRequest(
|
||||
message:
|
||||
'MapService does not support `update` with ${data.runtimeType}.');
|
||||
}
|
||||
//if (data is! Map) {
|
||||
// throw AngelHttpException.badRequest(
|
||||
// message:
|
||||
// 'MapService does not support `update` with ${data.runtimeType}.');
|
||||
//}
|
||||
if (!items.any(_matchesId(id))) return create(data, params);
|
||||
|
||||
return read(id).then((old) {
|
||||
|
|
|
@ -83,10 +83,10 @@ class Parameter {
|
|||
final String? query;
|
||||
|
||||
/// Only execute the handler if the value of this parameter matches the given value.
|
||||
final match;
|
||||
final dynamic match;
|
||||
|
||||
/// Specify a default value.
|
||||
final defaultValue;
|
||||
final dynamic defaultValue;
|
||||
|
||||
/// If `true` (default), then an error will be thrown if this parameter is not present.
|
||||
final bool? required;
|
||||
|
@ -117,6 +117,8 @@ class Parameter {
|
|||
if (session?.isNotEmpty == true) {
|
||||
return StateError('Session does not contain required key "$session".');
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Obtains a value for this parameter from a [RequestContext].
|
||||
|
|
|
@ -82,8 +82,8 @@ class Angel extends Routable {
|
|||
///
|
||||
/// This value is memoized the first time you call it, so do not change environment
|
||||
/// configuration at runtime!
|
||||
@deprecated
|
||||
bool get isProduction => environment.isProduction;
|
||||
//@deprecated
|
||||
//bool get isProduction => environment.isProduction;
|
||||
|
||||
/// The [AngelEnvironment] in which the application is running.
|
||||
///
|
||||
|
|
|
@ -8,6 +8,7 @@ import 'http2_request_context.dart';
|
|||
class Http2ResponseContext extends ResponseContext<ServerTransportStream> {
|
||||
@override
|
||||
final Angel? app;
|
||||
|
||||
final ServerTransportStream stream;
|
||||
|
||||
@override
|
||||
|
|
|
@ -68,7 +68,7 @@ Future<void> hello(RequestContext req, ResponseContext res) {
|
|||
var s = Stream<List<int>>.fromIterable([bytes]);
|
||||
return s.pipe(res);
|
||||
} else {
|
||||
return Future.value(true);
|
||||
return Future.value();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -47,8 +47,8 @@ void main() {
|
|||
nested = Angel(reflector: MirrorsReflector());
|
||||
todos = Angel(reflector: MirrorsReflector());
|
||||
|
||||
[app, nested, todos].forEach((Angel? app) {
|
||||
app?.logger = Logger('routing_test')
|
||||
for (var app in [app, nested, todos]) {
|
||||
app.logger = Logger('routing_test')
|
||||
..onRecord.listen((rec) {
|
||||
if (rec.error != null) {
|
||||
stdout
|
||||
|
@ -57,7 +57,7 @@ void main() {
|
|||
..writeln(cyan.wrap(rec.stackTrace.toString()));
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
todos.get('/action/:action', (req, res) => res.json(req.params));
|
||||
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## 4.0.4
|
||||
|
||||
* Updated README
|
||||
* Removed deprecated
|
||||
|
||||
## 4.0.3
|
||||
|
||||
* Updated README
|
||||
|
|
|
@ -10,5 +10,5 @@ A database migration framework built for Angel3 ORM.
|
|||
## Supported database
|
||||
|
||||
* PostgreSQL version 10 or later
|
||||
* MySQL 8.0 or later
|
||||
* MariaDB 10.2.1 or later
|
||||
* MySQL 8.0.x
|
||||
* MariaDB 10.2.x
|
||||
|
|
|
@ -19,8 +19,8 @@ abstract class Table {
|
|||
|
||||
MigrationColumn date(String name) => declare(name, ColumnType.date);
|
||||
|
||||
@deprecated
|
||||
MigrationColumn dateTime(String name) => timeStamp(name, timezone: true);
|
||||
//@deprecated
|
||||
//MigrationColumn dateTime(String name) => timeStamp(name, timezone: true);
|
||||
|
||||
MigrationColumn timeStamp(String name, {bool timezone = false}) {
|
||||
if (timezone != true) return declare(name, ColumnType.timeStamp);
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
name: angel3_migration
|
||||
version: 4.0.3
|
||||
version: 4.1.0
|
||||
description: Database migration runtime for Angel3 ORM. Use this package to define schemas.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_orm: ^4.0.0
|
||||
angel3_orm: ^4.1.0
|
||||
dev_dependencies:
|
||||
lints: ^1.0.0
|
||||
dependency_overrides:
|
||||
angel3_orm:
|
||||
path: ../angel_orm
|
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 4.1.2
|
||||
|
||||
* Updated README
|
||||
|
||||
## 4.1.1
|
||||
|
||||
* Updated README
|
||||
|
|
|
@ -10,5 +10,5 @@ Command-line based database migration runner for Angel3 ORM.
|
|||
Supported database:
|
||||
|
||||
* PostgreSQL version 10 or later
|
||||
* MySQL 8.0 or later
|
||||
* MariaDB 10.2.1 or later
|
||||
* MySQL 8.0.x
|
||||
* MariaDB 10.2.x
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
name: angel3_migration_runner
|
||||
version: 4.1.1
|
||||
version: 4.1.2
|
||||
description: Command-line based database migration runner for Angel3's ORM.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_migration_runner
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_migration: ^4.0.0
|
||||
angel3_orm: ^4.0.0
|
||||
angel3_migration: ^4.1.0
|
||||
angel3_orm: ^4.1.0
|
||||
args: ^2.1.0
|
||||
charcode: ^1.2.0
|
||||
postgres: ^2.4.0
|
||||
|
@ -15,4 +15,8 @@ dependencies:
|
|||
logging: ^1.0.0
|
||||
dev_dependencies:
|
||||
lints: ^1.0.0
|
||||
|
||||
dependency_overrides:
|
||||
angel3_orm:
|
||||
path: ../angel_orm
|
||||
angel3_migration:
|
||||
path: ../angel_migration
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## 4.1.0
|
||||
|
||||
* Added `MySQLDialect` to handle MySQL database specific features
|
||||
* Updated `insert` and `update` query to support database without writable CTE
|
||||
|
||||
## 4.0.6
|
||||
|
||||
* Fixed multiple `orderBy` error
|
||||
|
|
|
@ -10,6 +10,7 @@ Runtime support for Angel3 ORM. Includes a clean, database-agnostic query builde
|
|||
## Supported database
|
||||
|
||||
* PostgreSQL version 10, 11, 12, 13 and 14
|
||||
* MySQL 8.0 or later
|
||||
* MariaDB 10.2.x
|
||||
* MySQL 8.0.x
|
||||
|
||||
For documentation about the ORM, see [Developer Guide](https://angel3-docs.dukefirehawk.com/guides/orm)
|
||||
|
|
|
@ -26,8 +26,9 @@ class _FakeExecutor extends QueryExecutor {
|
|||
|
||||
@override
|
||||
Future<List<List>> query(
|
||||
String tableName, String? query, Map<String, dynamic> substitutionValues,
|
||||
[returningFields = const []]) async {
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
{String returningQuery = '',
|
||||
List<String> returningFields = const []}) async {
|
||||
var now = DateTime.now();
|
||||
print(
|
||||
'_FakeExecutor received query: $query and values: $substitutionValues');
|
||||
|
@ -40,6 +41,11 @@ class _FakeExecutor extends QueryExecutor {
|
|||
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) {
|
||||
throw UnsupportedError('Transactions are not supported.');
|
||||
}
|
||||
|
||||
final Dialect _dialect = const PostgreSQLDialect();
|
||||
|
||||
@override
|
||||
Dialect get dialect => _dialect;
|
||||
}
|
||||
|
||||
@orm
|
||||
|
|
|
@ -13,3 +13,4 @@ export 'src/query.dart';
|
|||
export 'src/relations.dart';
|
||||
export 'src/union.dart';
|
||||
export 'src/util.dart';
|
||||
export 'src/dialect/dialect.dart';
|
||||
|
|
|
@ -238,7 +238,7 @@ class StringSqlExpressionBuilder extends SqlExpressionBuilder<String> {
|
|||
void like(String pattern, {String Function(String)? sanitize}) {
|
||||
sanitize ??= (s) => pattern;
|
||||
_raw = 'LIKE \'' + sanitize('@$substitution') + '\'';
|
||||
query.substitutionValues[substitution] = pattern;
|
||||
//query.substitutionValues[substitution] = pattern;
|
||||
_hasValue = true;
|
||||
_value = null;
|
||||
}
|
||||
|
|
25
packages/orm/angel_orm/lib/src/dialect/dialect.dart
Normal file
25
packages/orm/angel_orm/lib/src/dialect/dialect.dart
Normal file
|
@ -0,0 +1,25 @@
|
|||
abstract class Dialect {
|
||||
bool get cteSupport;
|
||||
|
||||
bool get writableCteSupport;
|
||||
}
|
||||
|
||||
class MySQLDialect implements Dialect {
|
||||
const MySQLDialect();
|
||||
|
||||
@override
|
||||
bool get cteSupport => true;
|
||||
|
||||
@override
|
||||
bool get writableCteSupport => false;
|
||||
}
|
||||
|
||||
class PostgreSQLDialect implements Dialect {
|
||||
const PostgreSQLDialect();
|
||||
|
||||
@override
|
||||
bool get cteSupport => true;
|
||||
|
||||
@override
|
||||
bool get writableCteSupport => true;
|
||||
}
|
|
@ -1,13 +1,7 @@
|
|||
import 'dart:async';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import 'annotations.dart';
|
||||
import 'join_builder.dart';
|
||||
import 'order_by.dart';
|
||||
import 'query_base.dart';
|
||||
import 'query_executor.dart';
|
||||
import 'query_values.dart';
|
||||
import 'query_where.dart';
|
||||
import 'package:optional/optional.dart';
|
||||
|
||||
/// A SQL `SELECT` query builder.
|
||||
|
@ -70,7 +64,7 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
|
|||
nn++;
|
||||
_names[name] = nn;
|
||||
} else {
|
||||
_names[name] = 1;
|
||||
_names[name] = 0; //1;
|
||||
}
|
||||
return n == 0 ? name : '$name$n';
|
||||
}
|
||||
|
@ -298,7 +292,7 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
|
|||
}
|
||||
return ss;
|
||||
}));
|
||||
_joins.forEach((j) {
|
||||
for (var j in _joins) {
|
||||
var c = compiledJoins[j] = j.compile(trampoline);
|
||||
//if (c != null) {
|
||||
if (c != '') {
|
||||
|
@ -310,7 +304,7 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
|
|||
f.add('NULL');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
if (withFields) b.write(f.join(', '));
|
||||
fromQuery ??= tableName;
|
||||
|
@ -349,12 +343,12 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
|
|||
Future<List<T>> delete(QueryExecutor executor) {
|
||||
var sql = compile({}, preamble: 'DELETE', withFields: false);
|
||||
|
||||
//_log.fine("Delete Query = $sql");
|
||||
//_log.warning("Delete Query = $sql");
|
||||
|
||||
if (_joins.isEmpty) {
|
||||
return executor
|
||||
.query(tableName, sql, substitutionValues,
|
||||
fields.map(adornWithTableName).toList())
|
||||
returningFields: fields.map(adornWithTableName).toList())
|
||||
.then((it) => deserializeList(it));
|
||||
} else {
|
||||
return executor.transaction((tx) async {
|
||||
|
@ -379,14 +373,31 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
|
|||
if (insertion == '') {
|
||||
throw StateError('No values have been specified for update.');
|
||||
} else {
|
||||
// TODO: How to do this in a non-Postgres DB?
|
||||
var returning = fields.map(adornWithTableName).join(', ');
|
||||
var sql = compile({});
|
||||
sql = 'WITH $tableName as ($insertion RETURNING $returning) ' + sql;
|
||||
var returningSql = '';
|
||||
if (executor.dialect is PostgreSQLDialect) {
|
||||
var returning = fields.map(adornWithTableName).join(', ');
|
||||
sql = 'WITH $tableName as ($insertion RETURNING $returning) ' + sql;
|
||||
} else if (executor.dialect is MySQLDialect) {
|
||||
// Default to using 'id' as primary key in model
|
||||
if (fields.contains("id")) {
|
||||
returningSql = '$sql where $tableName.id=?';
|
||||
} else {
|
||||
var returningSelect = values?.compileInsertSelect(this, tableName);
|
||||
returningSql = '$sql where $returningSelect';
|
||||
}
|
||||
|
||||
//_log.fine("Insert Query = $sql");
|
||||
sql = '$insertion';
|
||||
} else {
|
||||
throw ArgumentError("Unsupported database dialect.");
|
||||
}
|
||||
|
||||
return executor.query(tableName, sql, substitutionValues).then((it) {
|
||||
//_log.warning("Insert Query = $sql");
|
||||
|
||||
return executor
|
||||
.query(tableName, sql, substitutionValues,
|
||||
returningQuery: returningSql)
|
||||
.then((it) {
|
||||
// Return SQL execution results
|
||||
return it.isEmpty ? Optional.empty() : deserialize(it.first);
|
||||
});
|
||||
|
@ -399,24 +410,30 @@ abstract class Query<T, Where extends QueryWhere> extends QueryBase<T> {
|
|||
|
||||
if (valuesClause == '') {
|
||||
throw StateError('No values have been specified for update.');
|
||||
} else {
|
||||
updateSql.write(' $valuesClause');
|
||||
var whereClause = where?.compile();
|
||||
if (whereClause?.isNotEmpty == true) {
|
||||
updateSql.write(' WHERE $whereClause');
|
||||
}
|
||||
if (_limit != null) updateSql.write(' LIMIT $_limit');
|
||||
|
||||
var returning = fields.map(adornWithTableName).join(', ');
|
||||
var sql = compile({});
|
||||
sql = 'WITH $tableName as ($updateSql RETURNING $returning) ' + sql;
|
||||
|
||||
//_log.fine("Update Query = $sql");
|
||||
|
||||
return executor
|
||||
.query(tableName, sql, substitutionValues)
|
||||
.then((it) => deserializeList(it));
|
||||
}
|
||||
updateSql.write(' $valuesClause');
|
||||
var whereClause = where?.compile();
|
||||
if (whereClause?.isNotEmpty == true) {
|
||||
updateSql.write(' WHERE $whereClause');
|
||||
}
|
||||
if (_limit != null) updateSql.write(' LIMIT $_limit');
|
||||
|
||||
var returning = fields.map(adornWithTableName).join(', ');
|
||||
var sql = compile({});
|
||||
var returningSql = '';
|
||||
if (executor.dialect is PostgreSQLDialect) {
|
||||
sql = 'WITH $tableName as ($updateSql RETURNING $returning) ' + sql;
|
||||
} else if (executor.dialect is MySQLDialect) {
|
||||
returningSql = sql;
|
||||
sql = '$updateSql';
|
||||
} else {
|
||||
throw ArgumentError("Unsupported database dialect.");
|
||||
}
|
||||
//_log.fine("Update Query = $sql");
|
||||
|
||||
return executor
|
||||
.query(tableName, sql, substitutionValues, returningQuery: returningSql)
|
||||
.then((it) => deserializeList(it));
|
||||
}
|
||||
|
||||
Future<Optional<T>> updateOne(QueryExecutor executor) {
|
||||
|
|
|
@ -45,11 +45,11 @@ abstract class QueryBase<T> {
|
|||
List<T> deserializeList(List<List<dynamic>> it) {
|
||||
var optResult = it.map(deserialize).toList();
|
||||
var result = <T>[];
|
||||
optResult.forEach((element) {
|
||||
for (var element in optResult) {
|
||||
element.ifPresent((item) {
|
||||
result.add(item);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -57,8 +57,8 @@ abstract class QueryBase<T> {
|
|||
Future<List<T>> get(QueryExecutor executor) async {
|
||||
var sql = compile({});
|
||||
|
||||
//_log.fine('sql = $sql');
|
||||
//_log.fine('substitutionValues = $substitutionValues');
|
||||
print('sql = $sql');
|
||||
print('substitutionValues = $substitutionValues');
|
||||
|
||||
return executor.query(tableName, sql, substitutionValues).then((it) {
|
||||
return deserializeList(it);
|
||||
|
|
|
@ -1,15 +1,23 @@
|
|||
import 'dart:async';
|
||||
|
||||
import '../angel3_orm.dart';
|
||||
|
||||
/// An abstract interface that performs queries.
|
||||
///
|
||||
/// This class should be implemented.
|
||||
abstract class QueryExecutor {
|
||||
const QueryExecutor();
|
||||
|
||||
Dialect get dialect;
|
||||
|
||||
/// Executes a single query.
|
||||
Future<List<List>> query(
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
[List<String> returningFields = const []]);
|
||||
String tableName,
|
||||
String query,
|
||||
Map<String, dynamic> substitutionValues, {
|
||||
String returningQuery = '',
|
||||
List<String> returningFields = const [],
|
||||
});
|
||||
|
||||
/// Enters a database transaction, performing the actions within,
|
||||
/// and returning the results of [f].
|
||||
|
|
|
@ -52,6 +52,20 @@ abstract class QueryValues {
|
|||
return b.toString();
|
||||
}
|
||||
|
||||
String compileInsertSelect(Query query, String tableName) {
|
||||
var data = Map<String, dynamic>.from(toMap());
|
||||
|
||||
var b = StringBuffer();
|
||||
var i = 0;
|
||||
|
||||
for (var entry in data.entries) {
|
||||
if (i++ > 0) b.write(' AND ');
|
||||
b.write('$tableName.${entry.key} = ?');
|
||||
}
|
||||
|
||||
return b.toString();
|
||||
}
|
||||
|
||||
String compileForUpdate(Query query) {
|
||||
var data = toMap();
|
||||
if (data.isEmpty) {
|
||||
|
|
|
@ -1,3 +1,21 @@
|
|||
import 'package:charcode/ascii.dart';
|
||||
|
||||
bool isAscii(int ch) => ch >= $nul && ch <= $del;
|
||||
|
||||
bool mapToBool(dynamic value) {
|
||||
if (value is int) {
|
||||
return value != 0;
|
||||
}
|
||||
|
||||
return value != null ? value as bool : false;
|
||||
}
|
||||
|
||||
String mapToText(dynamic value) {
|
||||
if (value == null) {
|
||||
return '';
|
||||
}
|
||||
if (value is! String) {
|
||||
return value.toString();
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
name: angel3_orm
|
||||
version: 4.0.6
|
||||
version: 4.1.0
|
||||
description: Runtime support for Angel3 ORM. Includes base classes for queries.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## 5.0.0
|
||||
|
||||
* Updated `analyzer` to version 3.x
|
||||
* Updated min SDK to 2.14.x
|
||||
|
||||
## 4.3.0
|
||||
|
||||
* Added `where.raw()`
|
||||
|
|
|
@ -21,8 +21,12 @@ class _FakeExecutor extends QueryExecutor {
|
|||
|
||||
@override
|
||||
Future<List<List>> query(
|
||||
String tableName, String? query, Map<String, dynamic> substitutionValues,
|
||||
[returningFields = const []]) async {
|
||||
String tableName,
|
||||
String? query,
|
||||
Map<String, dynamic> substitutionValues, {
|
||||
String returningQuery = '',
|
||||
List<String> returningFields = const [],
|
||||
}) async {
|
||||
var now = DateTime.now();
|
||||
print(
|
||||
'_FakeExecutor received query: $query and values: $substitutionValues');
|
||||
|
@ -35,6 +39,10 @@ class _FakeExecutor extends QueryExecutor {
|
|||
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) {
|
||||
throw UnsupportedError('Transactions are not supported.');
|
||||
}
|
||||
|
||||
@override
|
||||
// TODO: implement dialect
|
||||
Dialect get dialect => PostgreSQLDialect();
|
||||
}
|
||||
|
||||
@orm
|
||||
|
|
|
@ -110,7 +110,8 @@ class OrmGenerator extends GeneratorForAnnotation<Orm> {
|
|||
var type = ctx.columns[field.name]?.type;
|
||||
if (type == null) continue;
|
||||
if (floatTypes.contains(type)) {
|
||||
args[name] = literalString('text');
|
||||
//args[name] = literalString('text');
|
||||
args[name] = literalString('char');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,16 +1,16 @@
|
|||
name: angel3_orm_generator
|
||||
version: 4.3.0
|
||||
version: 5.0.0
|
||||
description: Code generators for Angel3 ORM. Generates query builder classes.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_generator
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: '>=2.14.0 <3.0.0'
|
||||
dependencies:
|
||||
analyzer: ^2.0.0
|
||||
analyzer: ^3.0.0
|
||||
angel3_model: ^3.0.0
|
||||
angel3_serialize: ^4.0.0
|
||||
angel3_orm: ^4.0.0
|
||||
angel3_serialize_generator: ^4.0.0
|
||||
angel3_orm: ^4.1.0
|
||||
angel3_serialize_generator: ^5.0.0
|
||||
inflection3: ^0.5.3+1
|
||||
build: ^2.0.1
|
||||
build_config: ^1.0.0
|
||||
|
@ -25,7 +25,7 @@ dependencies:
|
|||
optional: ^6.0.0
|
||||
dev_dependencies:
|
||||
angel3_framework: ^4.2.0
|
||||
angel3_migration: ^4.0.0
|
||||
angel3_migration: ^4.1.0
|
||||
build_runner: ^2.0.1
|
||||
postgres: ^2.4.0
|
||||
test: ^1.17.3
|
||||
|
@ -35,4 +35,6 @@ dependency_overrides:
|
|||
path: ../angel_orm
|
||||
angel3_migration:
|
||||
path: ../angel_migration
|
||||
angel3_serialize_generator:
|
||||
path: ../../serialize/angel_serialize_generator
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
import 'package:angel3_migration/angel3_migration.dart';
|
||||
import 'package:angel3_model/angel3_model.dart';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:angel3_orm_mysql/angel3_orm_mysql.dart';
|
||||
import 'package:angel3_serialize/angel3_serialize.dart';
|
||||
//import 'package:galileo_sqljocky5/sqljocky.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:galileo_sqljocky5/sqljocky.dart';
|
||||
import 'package:mysql1/mysql1.dart';
|
||||
import 'package:optional/optional.dart';
|
||||
part 'main.g.dart';
|
||||
|
||||
|
@ -15,9 +15,14 @@ void main() async {
|
|||
..onRecord.listen(print);
|
||||
|
||||
var settings = ConnectionSettings(
|
||||
db: 'angel_orm_test', user: 'angel_orm_test', password: 'angel_orm_test');
|
||||
host: 'localhost',
|
||||
port: 3306,
|
||||
db: 'orm_test',
|
||||
user: 'Test',
|
||||
password: 'Test123*');
|
||||
var connection = await MySqlConnection.connect(settings);
|
||||
var logger = Logger('angel_orm_mysql');
|
||||
|
||||
var logger = Logger('orm_mysql');
|
||||
var executor = MySqlExecutor(connection, logger: logger);
|
||||
|
||||
var query = TodoQuery();
|
||||
|
|
|
@ -69,7 +69,7 @@ class TodoQuery extends Query<Todo, TodoQueryWhere> {
|
|||
if (row.every((x) => x == null)) return null;
|
||||
var model = Todo(
|
||||
id: row[0].toString(),
|
||||
isComplete: (row[1] as bool?),
|
||||
isComplete: (row[1] as int?) != 0,
|
||||
text: (row[2] as String?),
|
||||
createdAt: (row[3] as DateTime?),
|
||||
updatedAt: (row[4] as DateTime?));
|
||||
|
|
|
@ -1,26 +1,33 @@
|
|||
import 'dart:async';
|
||||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
// import 'package:pool/pool.dart';
|
||||
import 'package:galileo_sqljocky5/public/connection/connection.dart';
|
||||
import 'package:galileo_sqljocky5/sqljocky.dart';
|
||||
import 'package:mysql1/mysql1.dart';
|
||||
|
||||
class MySqlExecutor extends QueryExecutor {
|
||||
/// An optional [Logger] to write to.
|
||||
final Logger? logger;
|
||||
|
||||
final Querier? _connection;
|
||||
final MySqlConnection _connection;
|
||||
|
||||
MySqlExecutor(this._connection, {this.logger});
|
||||
|
||||
final Dialect _dialect = const MySQLDialect();
|
||||
|
||||
@override
|
||||
Dialect get dialect => _dialect;
|
||||
|
||||
Future<void> close() {
|
||||
return _connection.close();
|
||||
/*
|
||||
if (_connection is MySqlConnection) {
|
||||
return (_connection as MySqlConnection).close();
|
||||
} else {
|
||||
return Future.value();
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
Future<Transaction> _startTransaction() {
|
||||
if (_connection is Transaction) {
|
||||
return Future.value(_connection as Transaction?);
|
||||
|
@ -30,7 +37,7 @@ class MySqlExecutor extends QueryExecutor {
|
|||
throw StateError('Connection must be transaction or connection');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@override
|
||||
Future<List<List>> query(
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
|
@ -69,7 +76,64 @@ class MySqlExecutor extends QueryExecutor {
|
|||
});
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@override
|
||||
Future<List<List>> query(
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
{String returningQuery = '',
|
||||
List<String> returningFields = const []}) async {
|
||||
// Change @id -> ?
|
||||
for (var name in substitutionValues.keys) {
|
||||
query = query.replaceAll('@$name', '?');
|
||||
}
|
||||
|
||||
var params = substitutionValues.values.toList();
|
||||
|
||||
//logger?.warning('Query: $query');
|
||||
//logger?.warning('Values: $params');
|
||||
//logger?.warning('Returning Query: $returningQuery');
|
||||
|
||||
if (returningQuery.isNotEmpty) {
|
||||
// Handle insert, update and delete
|
||||
// Retrieve back the inserted record
|
||||
if (query.startsWith("INSERT")) {
|
||||
var result = await _connection.query(query, params);
|
||||
|
||||
query = returningQuery;
|
||||
//logger?.warning('Result.insertId: ${result.insertId}');
|
||||
// Has primary key
|
||||
//if (result.insertId != 0) {
|
||||
if (returningQuery.endsWith('.id=?')) {
|
||||
params = [result.insertId];
|
||||
}
|
||||
} else if (query.startsWith("UPDATE")) {
|
||||
await _connection.query(query, params);
|
||||
query = returningQuery;
|
||||
params = [];
|
||||
}
|
||||
}
|
||||
|
||||
// Handle select
|
||||
return _connection.query(query, params).then((results) {
|
||||
return results.map((r) => r.toList()).toList();
|
||||
});
|
||||
}
|
||||
|
||||
@override
|
||||
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
|
||||
return f(this);
|
||||
/*
|
||||
if (_connection is! MySqlConnection) {
|
||||
return await f(this);
|
||||
}
|
||||
|
||||
await _connection.transaction((context) async {
|
||||
var executor = MySqlExecutor(context, logger: logger);
|
||||
});
|
||||
*/
|
||||
}
|
||||
/*
|
||||
@override
|
||||
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
|
||||
if (_connection is Transaction) {
|
||||
|
@ -88,4 +152,5 @@ class MySqlExecutor extends QueryExecutor {
|
|||
rethrow;
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
|
|
@ -6,17 +6,13 @@ repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel
|
|||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_orm: ^4.0.0
|
||||
angel3_orm: ^4.1.0
|
||||
logging: ^1.0.0
|
||||
pool: ^1.5.0
|
||||
galileo_sqljocky5: ^3.0.0
|
||||
mysql1: ^0.19.0
|
||||
optional: ^6.0.0
|
||||
dev_dependencies:
|
||||
angel3_migration: ^4.0.0
|
||||
angel3_orm_generator: ^4.0.0
|
||||
build_runner: ^2.0.0
|
||||
test: ^1.17.0
|
||||
angel3_orm_test: ^3.0.0
|
||||
test: ^1.17.0
|
||||
lints: ^1.0.0
|
||||
dependency_overrides:
|
||||
angel3_orm_test:
|
||||
|
|
|
@ -10,7 +10,7 @@ void main() {
|
|||
if (rec.stackTrace != null) print(rec.stackTrace);
|
||||
});
|
||||
|
||||
group('postgresql', () {
|
||||
group('mysql', () {
|
||||
group('belongsTo',
|
||||
() => belongsToTests(my(['author', 'book']), close: closeMy));
|
||||
group(
|
||||
|
@ -20,8 +20,10 @@ void main() {
|
|||
group('enumAndNested',
|
||||
() => enumAndNestedTests(my(['has_car']), close: closeMy));
|
||||
group('hasMany', () => hasManyTests(my(['tree', 'fruit']), close: closeMy));
|
||||
group('hasMap', () => hasMapTests(my(['has_map']), close: closeMy));
|
||||
group('hasOne', () => hasOneTests(my(['leg', 'foot']), close: closeMy));
|
||||
// NOTE: MySQL/MariaDB do not support jsonb data type
|
||||
//group('hasMap', () => hasMapTests(my(['has_map']), close: closeMy));
|
||||
// NOTE: mysql1 driver do not support CAST();
|
||||
//group('hasOne', () => hasOneTests(my(['leg', 'foot']), close: closeMy));
|
||||
group(
|
||||
'manyToMany',
|
||||
() =>
|
||||
|
|
|
@ -3,7 +3,7 @@ import 'dart:io';
|
|||
import 'package:angel3_orm/angel3_orm.dart';
|
||||
import 'package:angel3_orm_mysql/angel3_orm_mysql.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
import 'package:galileo_sqljocky5/sqljocky.dart';
|
||||
import 'package:mysql1/mysql1.dart';
|
||||
|
||||
FutureOr<QueryExecutor> Function() my(Iterable<String> schemas) {
|
||||
return () => connectToMySql(schemas);
|
||||
|
@ -14,15 +14,24 @@ Future<void> closeMy(QueryExecutor executor) =>
|
|||
|
||||
Future<MySqlExecutor> connectToMySql(Iterable<String> schemas) async {
|
||||
var settings = ConnectionSettings(
|
||||
db: 'angel_orm_test',
|
||||
user: Platform.environment['MYSQL_USERNAME'] ?? 'angel_orm_test',
|
||||
password: Platform.environment['MYSQL_PASSWORD'] ?? 'angel_orm_test');
|
||||
db: 'orm_test',
|
||||
host: "localhost",
|
||||
user: Platform.environment['MYSQL_USERNAME'] ?? 'Test',
|
||||
password: Platform.environment['MYSQL_PASSWORD'] ?? 'Test123*',
|
||||
timeout: Duration(minutes: 10));
|
||||
var connection = await MySqlConnection.connect(settings);
|
||||
var logger = Logger('angel_orm_mysql');
|
||||
var logger = Logger('orm_mysql');
|
||||
|
||||
for (var s in schemas) {
|
||||
await connection
|
||||
.execute(await File('test/migrations/$s.sql').readAsString());
|
||||
// MySQL driver does not support multiple sql queries
|
||||
var data = await File('test/migrations/$s.sql').readAsString();
|
||||
var queries = data.split(";");
|
||||
for (var q in queries) {
|
||||
//print("Table: [$q]");
|
||||
if (q.trim().isNotEmpty) {
|
||||
await connection.query(q);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return MySqlExecutor(connection, logger: logger);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "authors" (
|
||||
CREATE TEMPORARY TABLE authors (
|
||||
id serial PRIMARY KEY,
|
||||
name varchar(255) UNIQUE NOT NULL,
|
||||
created_at timestamp,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "books" (
|
||||
CREATE TEMPORARY TABLE books (
|
||||
id serial PRIMARY KEY,
|
||||
author_id int NOT NULL,
|
||||
partner_author_id int,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "cars" (
|
||||
CREATE TEMPORARY TABLE cars (
|
||||
id serial PRIMARY KEY,
|
||||
make varchar(255) NOT NULL,
|
||||
description TEXT NOT NULL,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "feet" (
|
||||
CREATE TEMPORARY TABLE feet (
|
||||
id serial PRIMARY KEY,
|
||||
leg_id int NOT NULL,
|
||||
n_toes int NOT NULL,
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
CREATE TEMPORARY TABLE "fruits" (
|
||||
"id" serial,
|
||||
"tree_id" int,
|
||||
"common_name" varchar,
|
||||
"created_at" timestamp,
|
||||
"updated_at" timestamp,
|
||||
CREATE TEMPORARY TABLE fruits (
|
||||
id serial,
|
||||
tree_id int,
|
||||
common_name varchar(255),
|
||||
created_at timestamp,
|
||||
updated_at timestamp,
|
||||
PRIMARY KEY(id)
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "has_cars" (
|
||||
CREATE TEMPORARY TABLE has_cars (
|
||||
id serial PRIMARY KEY,
|
||||
type int not null,
|
||||
created_at timestamp,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "has_maps" (
|
||||
CREATE TEMPORARY TABLE has_maps (
|
||||
id serial PRIMARY KEY,
|
||||
value jsonb not null,
|
||||
list jsonb not null,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "legs" (
|
||||
CREATE TEMPORARY TABLE legs (
|
||||
id serial PRIMARY KEY,
|
||||
name varchar(255) NOT NULL,
|
||||
created_at timestamp,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CREATE TEMPORARY TABLE "numbas" (
|
||||
"i" int,
|
||||
"parent" int references weird_joins(id),
|
||||
CREATE TEMPORARY TABLE numbas (
|
||||
i int NOT NULL UNIQUE,
|
||||
parent int,
|
||||
created_at TIMESTAMP,
|
||||
updated_at TIMESTAMP,
|
||||
PRIMARY KEY(i)
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
CREATE TEMPORARY TABLE "roles" (
|
||||
"id" serial PRIMARY KEY,
|
||||
"name" varchar(255),
|
||||
"created_at" timestamp,
|
||||
"updated_at" timestamp
|
||||
CREATE TEMPORARY TABLE roles (
|
||||
id serial PRIMARY KEY,
|
||||
name varchar(255),
|
||||
created_at timestamp,
|
||||
updated_at timestamp
|
||||
);
|
|
@ -1,7 +1,7 @@
|
|||
CREATE TEMPORARY TABLE "songs" (
|
||||
"id" serial,
|
||||
"weird_join_id" int references weird_joins(id),
|
||||
"title" varchar(255),
|
||||
CREATE TEMPORARY TABLE songs (
|
||||
id serial,
|
||||
weird_join_id int,
|
||||
title varchar(255),
|
||||
created_at TIMESTAMP,
|
||||
updated_at TIMESTAMP,
|
||||
PRIMARY KEY(id)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
CREATE TEMPORARY TABLE "trees" (
|
||||
"id" serial,
|
||||
"rings" smallint UNIQUE,
|
||||
"created_at" timestamp,
|
||||
"updated_at" timestamp,
|
||||
UNIQUE(rings),
|
||||
CREATE TEMPORARY TABLE trees (
|
||||
id serial,
|
||||
rings smallint UNIQUE,
|
||||
created_at timestamp,
|
||||
updated_at timestamp,
|
||||
PRIMARY KEY(id)
|
||||
);
|
|
@ -1,4 +1,4 @@
|
|||
CREATE TEMPORARY TABLE "unorthodoxes" (
|
||||
"name" varchar(255),
|
||||
CREATE TEMPORARY TABLE unorthodoxes (
|
||||
name varchar(255) NOT NULL UNIQUE,
|
||||
PRIMARY KEY(name)
|
||||
);
|
|
@ -1,8 +1,8 @@
|
|||
CREATE TEMPORARY TABLE "users" (
|
||||
"id" serial PRIMARY KEY,
|
||||
"username" varchar(255),
|
||||
"password" varchar(255),
|
||||
"email" varchar(255),
|
||||
"created_at" timestamp,
|
||||
"updated_at" timestamp
|
||||
CREATE TEMPORARY TABLE users (
|
||||
id serial PRIMARY KEY,
|
||||
username varchar(255),
|
||||
password varchar(255),
|
||||
email varchar(255),
|
||||
created_at timestamp,
|
||||
updated_at timestamp
|
||||
);
|
|
@ -1,7 +1,7 @@
|
|||
CREATE TEMPORARY TABLE "role_users" (
|
||||
"id" serial PRIMARY KEY,
|
||||
"user_id" int NOT NULL,
|
||||
"role_id" int NOT NULL,
|
||||
"created_at" timestamp,
|
||||
"updated_at" timestamp
|
||||
CREATE TEMPORARY TABLE role_users (
|
||||
id serial PRIMARY KEY,
|
||||
user_id int NOT NULL,
|
||||
role_id int NOT NULL,
|
||||
created_at timestamp,
|
||||
updated_at timestamp
|
||||
);
|
|
@ -1,13 +1,15 @@
|
|||
CREATE TEMPORARY TABLE "weird_joins" (
|
||||
"id" serial,
|
||||
"join_name" varchar(255) references unorthodoxes(name),
|
||||
CREATE TEMPORARY TABLE weird_joins (
|
||||
id serial,
|
||||
join_name varchar(255),
|
||||
PRIMARY KEY(id)
|
||||
);
|
||||
CREATE TEMPORARY TABLE "foos" (
|
||||
"bar" varchar(255),
|
||||
|
||||
CREATE TEMPORARY TABLE foos (
|
||||
bar varchar(255) not null UNIQUE,
|
||||
PRIMARY KEY(bar)
|
||||
);
|
||||
CREATE TEMPORARY TABLE "foo_pivots" (
|
||||
"weird_join_id" int references weird_joins(id),
|
||||
"foo_bar" varchar(255) references foos(bar)
|
||||
);
|
||||
|
||||
CREATE TEMPORARY TABLE foo_pivots (
|
||||
weird_join_id int,
|
||||
foo_bar varchar(255)
|
||||
);
|
||||
|
|
21
packages/orm/angel_orm_mysql/test/orm_debug.dart
Normal file
21
packages/orm/angel_orm_mysql/test/orm_debug.dart
Normal file
|
@ -0,0 +1,21 @@
|
|||
import 'package:angel3_orm_test/angel3_orm_test.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
void main() async {
|
||||
//hierarchicalLoggingEnabled = true;
|
||||
Logger.root
|
||||
..level = Level.INFO
|
||||
..onRecord.listen(print);
|
||||
//Logger.root.onRecord.listen((rec) {
|
||||
// print(rec);
|
||||
// if (rec.error != null) print(rec.error);
|
||||
// if (rec.stackTrace != null) print(rec.stackTrace);
|
||||
//});
|
||||
|
||||
belongsToTests(my(['author', 'book']), close: closeMy);
|
||||
|
||||
//hasOneTests(my(['leg', 'foot']), close: closeMy);
|
||||
//standaloneTests(my(['car']), close: closeMy);
|
||||
}
|
|
@ -16,6 +16,11 @@ class PostgreSqlExecutor extends QueryExecutor {
|
|||
this.logger = logger ?? Logger('PostgreSqlExecutor');
|
||||
}
|
||||
|
||||
final Dialect _dialect = const PostgreSQLDialect();
|
||||
|
||||
@override
|
||||
Dialect get dialect => _dialect;
|
||||
|
||||
/// The underlying connection.
|
||||
PostgreSQLExecutionContext get connection => _connection;
|
||||
|
||||
|
@ -31,8 +36,8 @@ class PostgreSqlExecutor extends QueryExecutor {
|
|||
@override
|
||||
Future<PostgreSQLResult> query(
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
[List<String>? returningFields]) {
|
||||
if (returningFields != null && returningFields.isNotEmpty) {
|
||||
{String returningQuery = '', List<String> returningFields = const []}) {
|
||||
if (returningFields.isNotEmpty) {
|
||||
var fields = returningFields.join(', ');
|
||||
var returning = 'RETURNING $fields';
|
||||
query = '$query $returning';
|
||||
|
@ -119,6 +124,11 @@ class PostgreSqlExecutorPool extends QueryExecutor {
|
|||
assert(size > 0, 'Connection pool cannot be empty.');
|
||||
}
|
||||
|
||||
final Dialect _dialect = const PostgreSQLDialect();
|
||||
|
||||
@override
|
||||
Dialect get dialect => _dialect;
|
||||
|
||||
/// Closes all connections.
|
||||
Future close() async {
|
||||
await _pool.close();
|
||||
|
@ -151,11 +161,11 @@ class PostgreSqlExecutorPool extends QueryExecutor {
|
|||
@override
|
||||
Future<PostgreSQLResult> query(
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
[List<String>? returningFields]) {
|
||||
{String returningQuery = '', List<String> returningFields = const []}) {
|
||||
return _pool.withResource(() async {
|
||||
var executor = await _next();
|
||||
return executor.query(
|
||||
tableName, query, substitutionValues, returningFields);
|
||||
return executor.query(tableName, query, substitutionValues,
|
||||
returningFields: returningFields);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,11 @@ class PostgreSqlPoolExecutor extends QueryExecutor {
|
|||
this.logger = logger ?? Logger('PostgreSqlPoolExecutor');
|
||||
}
|
||||
|
||||
final Dialect _dialect = const PostgreSQLDialect();
|
||||
|
||||
@override
|
||||
Dialect get dialect => _dialect;
|
||||
|
||||
/// The underlying connection pooling.
|
||||
PgPool get pool => _pool;
|
||||
|
||||
|
@ -29,7 +34,7 @@ class PostgreSqlPoolExecutor extends QueryExecutor {
|
|||
@override
|
||||
Future<PostgreSQLResult> query(
|
||||
String tableName, String query, Map<String, dynamic> substitutionValues,
|
||||
[List<String> returningFields = const []]) {
|
||||
{String returningQuery = '', List<String> returningFields = const []}) {
|
||||
if (returningFields.isNotEmpty) {
|
||||
var fields = returningFields.join(', ');
|
||||
var returning = 'RETURNING $fields';
|
||||
|
|
|
@ -6,7 +6,7 @@ repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel
|
|||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_orm: ^4.0.0
|
||||
angel3_orm: ^4.1.0
|
||||
logging: ^1.0.1
|
||||
pool: ^1.5.0
|
||||
postgres: ^2.4.1
|
||||
|
@ -21,3 +21,5 @@ dependency_overrides:
|
|||
path: ../angel_orm_test
|
||||
angel3_orm:
|
||||
path: ../angel_orm
|
||||
angel3_migration:
|
||||
path: ../angel_migration
|
||||
|
|
18
packages/orm/angel_orm_postgres/test/orm_debug.dart
Normal file
18
packages/orm/angel_orm_postgres/test/orm_debug.dart
Normal file
|
@ -0,0 +1,18 @@
|
|||
import 'package:angel3_orm_test/angel3_orm_test.dart';
|
||||
import 'package:logging/logging.dart';
|
||||
|
||||
import 'common.dart';
|
||||
|
||||
void main() async {
|
||||
hierarchicalLoggingEnabled = true;
|
||||
Logger.root
|
||||
..level = Level.ALL
|
||||
..onRecord.listen(print);
|
||||
//Logger.root.onRecord.listen((rec) {
|
||||
// print(rec);
|
||||
// if (rec.error != null) print(rec.error);
|
||||
// if (rec.stackTrace != null) print(rec.stackTrace);
|
||||
//});
|
||||
|
||||
belongsToTests(pg(['author', 'book']), close: closePg);
|
||||
}
|
|
@ -5,18 +5,20 @@ import 'models/unorthodox.dart';
|
|||
|
||||
void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
||||
{FutureOr<void> Function(QueryExecutor)? close}) {
|
||||
late QueryExecutor executor;
|
||||
QueryExecutor? executor;
|
||||
close ??= (_) => null;
|
||||
|
||||
setUp(() async {
|
||||
executor = await createExecutor();
|
||||
});
|
||||
|
||||
tearDown(() => close!(executor));
|
||||
tearDown(() async {
|
||||
//await close!(executor!);
|
||||
});
|
||||
|
||||
test('can create object with no id', () async {
|
||||
var query = UnorthodoxQuery()..values.name = 'World';
|
||||
var modelOpt = await query.insert(executor);
|
||||
var modelOpt = await query.insert(executor!);
|
||||
expect(modelOpt.isPresent, true);
|
||||
modelOpt.ifPresent((model) {
|
||||
expect(model, Unorthodox(name: 'World'));
|
||||
|
@ -30,7 +32,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
//if (unorthodox == null) {
|
||||
var query = UnorthodoxQuery()..values.name = 'Hey';
|
||||
|
||||
var unorthodoxOpt = await query.insert(executor);
|
||||
var unorthodoxOpt = await query.insert(executor!);
|
||||
unorthodoxOpt.ifPresent((value) {
|
||||
unorthodox = value;
|
||||
});
|
||||
|
@ -39,7 +41,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
|
||||
test('belongs to', () async {
|
||||
var query = WeirdJoinQuery()..values.joinName = unorthodox!.name;
|
||||
var modelOpt = await query.insert(executor);
|
||||
var modelOpt = await query.insert(executor!);
|
||||
expect(modelOpt.isPresent, true);
|
||||
modelOpt.ifPresent((model) {
|
||||
//print(model.toJson());
|
||||
|
@ -55,7 +57,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
setUp(() async {
|
||||
var wjQuery = WeirdJoinQuery()..values.joinName = unorthodox!.name;
|
||||
|
||||
var weirdJoinOpt = await wjQuery.insert(executor);
|
||||
var weirdJoinOpt = await wjQuery.insert(executor!);
|
||||
//weirdJoin = (await wjQuery.insert(executor)).value;
|
||||
weirdJoinOpt.ifPresent((value1) async {
|
||||
weirdJoin = value1;
|
||||
|
@ -63,7 +65,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
..values.weirdJoinId = value1.id
|
||||
..values.title = 'Girl Blue';
|
||||
|
||||
var girlBlueOpt = await gbQuery.insert(executor);
|
||||
var girlBlueOpt = await gbQuery.insert(executor!);
|
||||
girlBlueOpt.ifPresent((value2) {
|
||||
girlBlue = value2;
|
||||
});
|
||||
|
@ -72,7 +74,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
|
||||
test('has one', () async {
|
||||
var query = WeirdJoinQuery()..where!.id.equals(weirdJoin!.id!);
|
||||
var wjOpt = await query.getOne(executor);
|
||||
var wjOpt = await query.getOne(executor!);
|
||||
expect(wjOpt.isPresent, true);
|
||||
wjOpt.ifPresent((wj) {
|
||||
//print(wj.toJson());
|
||||
|
@ -87,7 +89,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
var query = NumbaQuery()
|
||||
..values.parent = weirdJoin!.id
|
||||
..values.i = i;
|
||||
var modelObj = await query.insert(executor);
|
||||
var modelObj = await query.insert(executor!);
|
||||
expect(modelObj.isPresent, true);
|
||||
modelObj.ifPresent((model) {
|
||||
numbas.add(model);
|
||||
|
@ -95,7 +97,7 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
}
|
||||
|
||||
var query = WeirdJoinQuery()..where!.id.equals(weirdJoin!.id!);
|
||||
var wjObj = await query.getOne(executor);
|
||||
var wjObj = await query.getOne(executor!);
|
||||
expect(wjObj.isPresent, true);
|
||||
wjObj.ifPresent((wj) {
|
||||
//print(wj.toJson());
|
||||
|
@ -106,14 +108,14 @@ void edgeCaseTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
test('many to many', () async {
|
||||
var fooQuery = FooQuery()..values.bar = 'baz';
|
||||
var fooBar =
|
||||
await fooQuery.insert(executor).then((foo) => foo.value.bar);
|
||||
await fooQuery.insert(executor!).then((foo) => foo.value.bar);
|
||||
var pivotQuery = FooPivotQuery()
|
||||
..values.weirdJoinId = weirdJoin!.id
|
||||
..values.fooBar = fooBar;
|
||||
await pivotQuery.insert(executor);
|
||||
await pivotQuery.insert(executor!);
|
||||
fooQuery = FooQuery()..where!.bar.equals('baz');
|
||||
|
||||
var fooOpt = await fooQuery.getOne(executor);
|
||||
var fooOpt = await fooQuery.getOne(executor!);
|
||||
expect(fooOpt.isPresent, true);
|
||||
fooOpt.ifPresent((foo) {
|
||||
//print(foo.toJson());
|
||||
|
|
|
@ -203,7 +203,7 @@ class FootQuery extends Query<Foot, FootQueryWhere> {
|
|||
|
||||
@override
|
||||
Map<String, String> get casts {
|
||||
return {'n_toes': 'text'};
|
||||
return {'n_toes': 'char'};
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -48,7 +48,7 @@ class PersonOrderQuery extends Query<PersonOrder, PersonOrderQueryWhere> {
|
|||
|
||||
@override
|
||||
Map<String, String> get casts {
|
||||
return {'price': 'text'};
|
||||
return {'price': 'char'};
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -212,7 +212,7 @@ class OrderWithPersonInfoQuery
|
|||
|
||||
@override
|
||||
Map<String, String> get casts {
|
||||
return {'price': 'text'};
|
||||
return {'price': 'char'};
|
||||
}
|
||||
|
||||
@override
|
||||
|
|
|
@ -77,7 +77,7 @@ void standaloneTests(FutureOr<QueryExecutor> Function() createExecutor,
|
|||
|
||||
var sportsCars = CarQuery()..where!.familyFriendly.isFalse;
|
||||
cars = await sportsCars.get(executor!);
|
||||
//print(cars.map((c) => c.toJson()));
|
||||
print(cars.map((c) => c.toJson()));
|
||||
|
||||
var car = cars.first;
|
||||
expect(car.make, ferrari!.make);
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
name: angel3_orm_test
|
||||
version: 3.1.2
|
||||
version: 4.0.0
|
||||
description: Common tests for Angel3 ORM. Reference implmentation of the generated ORM files.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_test
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
angel3_migration: ^4.0.0
|
||||
angel3_migration: ^4.1.0
|
||||
angel3_model: ^3.1.0
|
||||
angel3_orm: ^4.0.0
|
||||
angel3_serialize: ^4.1.0
|
||||
|
@ -15,7 +15,7 @@ dependencies:
|
|||
collection: ^1.15.0
|
||||
optional: ^6.0.0
|
||||
dev_dependencies:
|
||||
angel3_orm_generator: ^4.1.0
|
||||
angel3_orm_generator: ^5.0.0
|
||||
angel3_framework: ^4.2.0
|
||||
build_runner: ^2.0.1
|
||||
lints: ^1.0.0
|
||||
|
@ -26,3 +26,5 @@ dependency_overrides:
|
|||
path: ../angel_orm_generator
|
||||
angel3_migration:
|
||||
path: ../angel_migration
|
||||
angel3_serialize_generator:
|
||||
path: ../../serialize/angel_serialize_generator
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
# Change Log
|
||||
|
||||
## 5.0.0
|
||||
|
||||
* Updated `analyzer` to version 3.x
|
||||
* Updated min SDK to 2.14.x
|
||||
|
||||
## 4.1.1
|
||||
|
||||
* Removed deprecated
|
||||
|
||||
## 4.1.0
|
||||
|
||||
* Updated README
|
||||
|
|
|
@ -87,8 +87,6 @@ class Serializable {
|
|||
const Serializable(
|
||||
{this.serializers = const [Serializers.map, Serializers.json],
|
||||
this.autoSnakeCaseNames = true,
|
||||
// ignore: deprecated_member_use_from_same_package
|
||||
//@deprecated this.autoIdAndDateFields = true,
|
||||
this.includeAnnotations = const []});
|
||||
|
||||
/// A list of enabled serialization modes.
|
||||
|
@ -99,10 +97,6 @@ class Serializable {
|
|||
/// Overrides the setting in `SerializerGenerator`.
|
||||
final bool autoSnakeCaseNames;
|
||||
|
||||
/// Overrides the setting in `JsonModelGenerator`.
|
||||
//@deprecated
|
||||
//final bool autoIdAndDateFields;
|
||||
|
||||
/// A list of constant members to affix to the generated class.
|
||||
final List includeAnnotations;
|
||||
}
|
||||
|
@ -130,20 +124,3 @@ abstract class Serializers {
|
|||
/// Generate a TypeScript definition file (`.d.ts`) for use on the client-side.
|
||||
static const int typescript = 2;
|
||||
}
|
||||
|
||||
/*
|
||||
@deprecated
|
||||
class DefaultValue {
|
||||
final value;
|
||||
|
||||
const DefaultValue(this.value);
|
||||
}
|
||||
|
||||
@deprecated
|
||||
/// Prefer [SerializableField] instead.
|
||||
class Alias {
|
||||
final String name;
|
||||
|
||||
const Alias(this.name);
|
||||
}
|
||||
*/
|
|
@ -1,8 +1,8 @@
|
|||
name: angel3_serialize
|
||||
version: 4.1.0
|
||||
version: 4.1.1
|
||||
description: Static annotations powering Angel3 model serialization. Combine with angel3_serialize_generator for flexible modeling.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/serialize/angel_serialize
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/serialize/angel_serialize
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
dependencies:
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
# Change Log
|
||||
|
||||
## 5.0.0
|
||||
|
||||
* Updated `analyzer` to version 3.x
|
||||
* Updated min SDK to 2.14.x
|
||||
|
||||
## 4.3.0
|
||||
|
||||
* Updated to use `package:belatuk_code_buffer`
|
||||
|
|
|
@ -7,7 +7,6 @@ import 'package:analyzer/dart/constant/value.dart';
|
|||
import 'package:analyzer/dart/element/element.dart';
|
||||
import 'package:analyzer/dart/element/nullability_suffix.dart';
|
||||
import 'package:analyzer/dart/element/type.dart';
|
||||
import 'package:angel3_model/angel3_model.dart';
|
||||
import 'package:angel3_serialize/angel3_serialize.dart';
|
||||
import 'package:build/build.dart';
|
||||
import 'package:belatuk_code_buffer/belatuk_code_buffer.dart';
|
||||
|
|
|
@ -5,7 +5,6 @@ import 'package:analyzer/dart/element/type.dart';
|
|||
import 'package:analyzer/src/dart/element/element.dart';
|
||||
import 'package:angel3_serialize/angel3_serialize.dart';
|
||||
import 'package:build/build.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
import 'package:path/path.dart' as p;
|
||||
import 'package:recase/recase.dart';
|
||||
import 'package:source_gen/source_gen.dart';
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
name: angel3_serialize_generator
|
||||
version: 4.3.0
|
||||
version: 5.0.0
|
||||
description: Angel3 model serialization generators, designed for use with Angel. Combine with angel_serialize for flexible modeling.
|
||||
homepage: https://angel3-framework.web.app/
|
||||
repository: https://github.com/dukefirehawk/angel/tree/angel3/packages/serialize/angel_serialize_generator
|
||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/serialize/angel_serialize_generator
|
||||
environment:
|
||||
sdk: '>=2.12.0 <3.0.0'
|
||||
sdk: '>=2.14.0 <3.0.0'
|
||||
dependencies:
|
||||
analyzer: ^2.0.0
|
||||
analyzer: ^3.0.0
|
||||
angel3_model: ^3.0.0
|
||||
angel3_serialize: ^4.1.0
|
||||
belatuk_code_buffer: ^3.0.0
|
||||
|
|
Loading…
Reference in a new issue