Skip to content

Commit

Permalink
Merge pull request #22 from TimWhiting/develop
Browse files Browse the repository at this point in the history
update to latest packages (except analyzer)
  • Loading branch information
schultek authored Sep 15, 2022
2 parents be13933 + 682ef26 commit 14045b3
Show file tree
Hide file tree
Showing 8 changed files with 111 additions and 109 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
.dart_tool/
.packages
build/
.vscode/

pubspec.lock

Expand Down
4 changes: 2 additions & 2 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ dependencies:
path: ../

dev_dependencies:
build_runner: ^2.1.7
lints: ^1.0.1
build_runner: ^2.2.1
lints: ^2.0.0
20 changes: 10 additions & 10 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,21 @@ repository: https://github.com/schultek/stormberry
issue_tracker: https://github.com/schultek/stormberry/issues

dependencies:
analyzer: ^3.3.1
analyzer: ">=4.2.0 <5.0.0"
args: ^2.3.1
build: ^2.2.1
build: ^2.3.1
collection: ^1.16.0
crypto: ^3.0.1
dart_style: ^2.2.2
crypto: ^3.0.2
dart_style: ^2.2.4
path: ^1.8.2
postgres: ^2.4.3
source_gen: ^1.2.1
yaml: ^3.1.0
postgres: ^2.5.1
source_gen: ^1.2.3
yaml: ^3.1.1

dev_dependencies:
build_runner: ^2.2.0
lints: ^1.0.1
test: ^1.21.1
lints: ^2.0.0
test: ^1.21.6

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.16.0 <3.0.0'
43 changes: 22 additions & 21 deletions test/packages/multi_schema/lib/modelsA.schema.g.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: prefer_relative_imports
import 'package:stormberry/internals.dart';
import 'package:multi_schema_test/modelsA.dart';

import 'modelsA.dart';

extension Repositories on Database {
ModelARepository get modelAs => ModelARepository._(this);
Expand All @@ -12,7 +13,7 @@ abstract class ModelARepository
implements ModelRepository, ModelRepositoryInsert<ModelAInsertRequest>, ModelRepositoryUpdate<ModelAUpdateRequest> {
factory ModelARepository._(Database db) = _ModelARepository;

Future<List<ViewaModelAView>> queryViewaViews([QueryParams? params]);
Future<List<ViewAModelAView>> queryViewAViews([QueryParams? params]);
}

class _ModelARepository extends BaseRepository
Expand All @@ -21,30 +22,30 @@ class _ModelARepository extends BaseRepository
_ModelARepository(Database db) : super(db: db);

@override
Future<List<ViewaModelAView>> queryViewaViews([QueryParams? params]) {
return queryMany(ViewaModelAViewQueryable(), params);
Future<List<ViewAModelAView>> queryViewAViews([QueryParams? params]) {
return queryMany(ViewAModelAViewQueryable(), params);
}

@override
Future<void> insert(Database db, List<ModelAInsertRequest> requests) async {
if (requests.isEmpty) return;
await db.query("""
INSERT INTO "model_as" ( "data" )
VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')}
""");

await db.query(
'INSERT INTO "model_as" ( "data" )\n'
'VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')}\n',
);
}

@override
Future<void> update(Database db, List<ModelAUpdateRequest> requests) async {
if (requests.isEmpty) return;
await db.query("""
UPDATE "model_as"
SET "data" = COALESCE(UPDATED."data"::text, "model_as"."data")
FROM ( VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')} )
AS UPDATED("data")
WHERE
""");
await db.query(
'UPDATE "model_as"\n'
'SET "data" = COALESCE(UPDATED."data"::text, "model_as"."data")\n'
'FROM ( VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')} )\n'
'AS UPDATED("data")\n'
'WHERE ',
);
}
}

Expand All @@ -58,17 +59,17 @@ class ModelAUpdateRequest {
String? data;
}

class ViewaModelAViewQueryable extends ViewQueryable<ViewaModelAView> {
class ViewAModelAViewQueryable extends ViewQueryable<ViewAModelAView> {
@override
String get tableName => 'viewa_model_as_view';
String get tableName => 'view_a_model_as_view';

@override
String get tableAlias => 'model_as';

@override
ViewaModelAView decode(TypedMap map) => ViewaModelAView();
ViewAModelAView decode(TypedMap map) => ViewAModelAView();
}

class ViewaModelAView {
ViewaModelAView();
class ViewAModelAView {
ViewAModelAView();
}
43 changes: 22 additions & 21 deletions test/packages/multi_schema/lib/modelsB.schema.g.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// ignore_for_file: prefer_relative_imports
import 'package:stormberry/internals.dart';
import 'package:multi_schema_test/modelsB.dart';

import 'modelsB.dart';

extension Repositories on Database {
ModelBRepository get modelBs => ModelBRepository._(this);
Expand All @@ -12,7 +13,7 @@ abstract class ModelBRepository
implements ModelRepository, ModelRepositoryInsert<ModelBInsertRequest>, ModelRepositoryUpdate<ModelBUpdateRequest> {
factory ModelBRepository._(Database db) = _ModelBRepository;

Future<List<ViewbModelBView>> queryViewbViews([QueryParams? params]);
Future<List<ViewBModelBView>> queryViewBViews([QueryParams? params]);
}

class _ModelBRepository extends BaseRepository
Expand All @@ -21,30 +22,30 @@ class _ModelBRepository extends BaseRepository
_ModelBRepository(Database db) : super(db: db);

@override
Future<List<ViewbModelBView>> queryViewbViews([QueryParams? params]) {
return queryMany(ViewbModelBViewQueryable(), params);
Future<List<ViewBModelBView>> queryViewBViews([QueryParams? params]) {
return queryMany(ViewBModelBViewQueryable(), params);
}

@override
Future<void> insert(Database db, List<ModelBInsertRequest> requests) async {
if (requests.isEmpty) return;
await db.query("""
INSERT INTO "model_bs" ( "data" )
VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')}
""");

await db.query(
'INSERT INTO "model_bs" ( "data" )\n'
'VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')}\n',
);
}

@override
Future<void> update(Database db, List<ModelBUpdateRequest> requests) async {
if (requests.isEmpty) return;
await db.query("""
UPDATE "model_bs"
SET "data" = COALESCE(UPDATED."data"::text, "model_bs"."data")
FROM ( VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')} )
AS UPDATED("data")
WHERE
""");
await db.query(
'UPDATE "model_bs"\n'
'SET "data" = COALESCE(UPDATED."data"::text, "model_bs"."data")\n'
'FROM ( VALUES ${requests.map((r) => '( ${registry.encode(r.data)} )').join(', ')} )\n'
'AS UPDATED("data")\n'
'WHERE ',
);
}
}

Expand All @@ -58,17 +59,17 @@ class ModelBUpdateRequest {
String? data;
}

class ViewbModelBViewQueryable extends ViewQueryable<ViewbModelBView> {
class ViewBModelBViewQueryable extends ViewQueryable<ViewBModelBView> {
@override
String get tableName => 'viewb_model_bs_view';
String get tableName => 'view_b_model_bs_view';

@override
String get tableAlias => 'model_bs';

@override
ViewbModelBView decode(TypedMap map) => ViewbModelBView();
ViewBModelBView decode(TypedMap map) => ViewBModelBView();
}

class ViewbModelBView {
ViewbModelBView();
class ViewBModelBView {
ViewBModelBView();
}
4 changes: 2 additions & 2 deletions test/packages/multi_schema/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ dependencies:
path: ../../../

dev_dependencies:
build_runner: ^2.1.7
lints: ^1.0.1
build_runner: ^2.2.1
lints: ^2.0.0
28 changes: 14 additions & 14 deletions test/packages/serialization/lib/models.mapper.g.dart
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ class UserInsertRequestMapper extends BaseMapper<UserInsertRequest> {

@override Function get decoder => decode;
UserInsertRequest decode(dynamic v) => checked(v, (Map<String, dynamic> map) => fromMap(map));
UserInsertRequest fromMap(Map<String, dynamic> map) => UserInsertRequest(companyId: Mapper.i.$getOpt(map, 'companyId'), id: Mapper.i.$get(map, 'id'), name: Mapper.i.$get(map, 'name'), securityNumber: Mapper.i.$get(map, 'securityNumber'));
UserInsertRequest fromMap(Map<String, dynamic> map) => UserInsertRequest(id: Mapper.i.$get(map, 'id'), name: Mapper.i.$get(map, 'name'), securityNumber: Mapper.i.$get(map, 'securityNumber'));

@override Function get encoder => (UserInsertRequest v) => encode(v);
dynamic encode(UserInsertRequest v) => toMap(v);
Map<String, dynamic> toMap(UserInsertRequest u) => {'companyId': Mapper.i.$enc(u.companyId, 'companyId'), 'id': Mapper.i.$enc(u.id, 'id'), 'name': Mapper.i.$enc(u.name, 'name'), 'securityNumber': Mapper.i.$enc(u.securityNumber, 'securityNumber')};
Map<String, dynamic> toMap(UserInsertRequest u) => {'id': Mapper.i.$enc(u.id, 'id'), 'name': Mapper.i.$enc(u.name, 'name'), 'securityNumber': Mapper.i.$enc(u.securityNumber, 'securityNumber')};

@override String stringify(UserInsertRequest self) => 'UserInsertRequest(companyId: ${Mapper.asString(self.companyId)}, id: ${Mapper.asString(self.id)}, name: ${Mapper.asString(self.name)}, securityNumber: ${Mapper.asString(self.securityNumber)})';
@override int hash(UserInsertRequest self) => Mapper.hash(self.companyId) ^ Mapper.hash(self.id) ^ Mapper.hash(self.name) ^ Mapper.hash(self.securityNumber);
@override bool equals(UserInsertRequest self, UserInsertRequest other) => Mapper.isEqual(self.companyId, other.companyId) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.name, other.name) && Mapper.isEqual(self.securityNumber, other.securityNumber);
@override String stringify(UserInsertRequest self) => 'UserInsertRequest(id: ${Mapper.asString(self.id)}, name: ${Mapper.asString(self.name)}, securityNumber: ${Mapper.asString(self.securityNumber)})';
@override int hash(UserInsertRequest self) => Mapper.hash(self.id) ^ Mapper.hash(self.name) ^ Mapper.hash(self.securityNumber);
@override bool equals(UserInsertRequest self, UserInsertRequest other) => Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.name, other.name) && Mapper.isEqual(self.securityNumber, other.securityNumber);

@override Function get typeFactory => (f) => f<UserInsertRequest>();
}
Expand All @@ -46,30 +46,30 @@ extension UserInsertRequestMapperExtension on UserInsertRequest {

abstract class UserInsertRequestCopyWith<$R> {
factory UserInsertRequestCopyWith(UserInsertRequest value, Then<UserInsertRequest, $R> then) = _UserInsertRequestCopyWithImpl<$R>;
$R call({String? companyId, String? id, String? name, String? securityNumber});
$R call({String? id, String? name, String? securityNumber});
$R apply(UserInsertRequest Function(UserInsertRequest) transform);
}

class _UserInsertRequestCopyWithImpl<$R> extends BaseCopyWith<UserInsertRequest, $R> implements UserInsertRequestCopyWith<$R> {
_UserInsertRequestCopyWithImpl(UserInsertRequest value, Then<UserInsertRequest, $R> then) : super(value, then);

@override $R call({Object? companyId = $none, String? id, String? name, String? securityNumber}) => $then(UserInsertRequest(companyId: or(companyId, $value.companyId), id: id ?? $value.id, name: name ?? $value.name, securityNumber: securityNumber ?? $value.securityNumber));
@override $R call({String? id, String? name, String? securityNumber}) => $then(UserInsertRequest(id: id ?? $value.id, name: name ?? $value.name, securityNumber: securityNumber ?? $value.securityNumber));
}

class UserUpdateRequestMapper extends BaseMapper<UserUpdateRequest> {
UserUpdateRequestMapper._();

@override Function get decoder => decode;
UserUpdateRequest decode(dynamic v) => checked(v, (Map<String, dynamic> map) => fromMap(map));
UserUpdateRequest fromMap(Map<String, dynamic> map) => UserUpdateRequest(companyId: Mapper.i.$getOpt(map, 'companyId'), id: Mapper.i.$get(map, 'id'), name: Mapper.i.$getOpt(map, 'name'), securityNumber: Mapper.i.$getOpt(map, 'securityNumber'));
UserUpdateRequest fromMap(Map<String, dynamic> map) => UserUpdateRequest(id: Mapper.i.$get(map, 'id'), name: Mapper.i.$getOpt(map, 'name'), securityNumber: Mapper.i.$getOpt(map, 'securityNumber'));

@override Function get encoder => (UserUpdateRequest v) => encode(v);
dynamic encode(UserUpdateRequest v) => toMap(v);
Map<String, dynamic> toMap(UserUpdateRequest u) => {'companyId': Mapper.i.$enc(u.companyId, 'companyId'), 'id': Mapper.i.$enc(u.id, 'id'), 'name': Mapper.i.$enc(u.name, 'name'), 'securityNumber': Mapper.i.$enc(u.securityNumber, 'securityNumber')};
Map<String, dynamic> toMap(UserUpdateRequest u) => {'id': Mapper.i.$enc(u.id, 'id'), 'name': Mapper.i.$enc(u.name, 'name'), 'securityNumber': Mapper.i.$enc(u.securityNumber, 'securityNumber')};

@override String stringify(UserUpdateRequest self) => 'UserUpdateRequest(companyId: ${Mapper.asString(self.companyId)}, id: ${Mapper.asString(self.id)}, name: ${Mapper.asString(self.name)}, securityNumber: ${Mapper.asString(self.securityNumber)})';
@override int hash(UserUpdateRequest self) => Mapper.hash(self.companyId) ^ Mapper.hash(self.id) ^ Mapper.hash(self.name) ^ Mapper.hash(self.securityNumber);
@override bool equals(UserUpdateRequest self, UserUpdateRequest other) => Mapper.isEqual(self.companyId, other.companyId) && Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.name, other.name) && Mapper.isEqual(self.securityNumber, other.securityNumber);
@override String stringify(UserUpdateRequest self) => 'UserUpdateRequest(id: ${Mapper.asString(self.id)}, name: ${Mapper.asString(self.name)}, securityNumber: ${Mapper.asString(self.securityNumber)})';
@override int hash(UserUpdateRequest self) => Mapper.hash(self.id) ^ Mapper.hash(self.name) ^ Mapper.hash(self.securityNumber);
@override bool equals(UserUpdateRequest self, UserUpdateRequest other) => Mapper.isEqual(self.id, other.id) && Mapper.isEqual(self.name, other.name) && Mapper.isEqual(self.securityNumber, other.securityNumber);

@override Function get typeFactory => (f) => f<UserUpdateRequest>();
}
Expand All @@ -82,14 +82,14 @@ extension UserUpdateRequestMapperExtension on UserUpdateRequest {

abstract class UserUpdateRequestCopyWith<$R> {
factory UserUpdateRequestCopyWith(UserUpdateRequest value, Then<UserUpdateRequest, $R> then) = _UserUpdateRequestCopyWithImpl<$R>;
$R call({String? companyId, String? id, String? name, String? securityNumber});
$R call({String? id, String? name, String? securityNumber});
$R apply(UserUpdateRequest Function(UserUpdateRequest) transform);
}

class _UserUpdateRequestCopyWithImpl<$R> extends BaseCopyWith<UserUpdateRequest, $R> implements UserUpdateRequestCopyWith<$R> {
_UserUpdateRequestCopyWithImpl(UserUpdateRequest value, Then<UserUpdateRequest, $R> then) : super(value, then);

@override $R call({Object? companyId = $none, String? id, Object? name = $none, Object? securityNumber = $none}) => $then(UserUpdateRequest(companyId: or(companyId, $value.companyId), id: id ?? $value.id, name: or(name, $value.name), securityNumber: or(securityNumber, $value.securityNumber)));
@override $R call({String? id, Object? name = $none, Object? securityNumber = $none}) => $then(UserUpdateRequest(id: id ?? $value.id, name: or(name, $value.name), securityNumber: or(securityNumber, $value.securityNumber)));
}

class DefaultUserViewMapper extends BaseMapper<DefaultUserView> {
Expand Down
Loading

0 comments on commit 14045b3

Please sign in to comment.