Skip to content

Commit d55a38f

Browse files
authored
fix(sqlite): enumAsString generates varchar column instead of integer #597 (#604)
1 parent 0a149ee commit d55a38f

File tree

51 files changed

+958
-849
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+958
-849
lines changed

packages/brick_build/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ environment:
1212
dependencies:
1313
analyzer: ">=6.11.0 <8.0.0"
1414
brick_core: ">=2.0.0 <3.0.0"
15-
build: ">=2.4.2 <3.0.0"
15+
build: ">=2.4.2 <2.5.0"
1616
dart_style: ">=3.0.0 <4.0.0"
1717
glob: ">=2.1.0 <3.0.0"
1818
logging: ">=1.0.0 <2.0.0"

packages/brick_build_test/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ environment:
1212
sdk: ">=3.4.0 <4.0.0"
1313

1414
dependencies:
15-
build: ">=2.4.2 <3.0.0"
15+
build: ">=2.4.2 <2.5.0"
1616
path: ">=1.9.0 <2.0.0"
1717
source_gen: ">=1.5.0 <3.0.0"
1818
source_gen_test: ">=1.0.0 <2.0.0"

packages/brick_graphql_generators/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ dependencies:
1515
brick_core: ">=2.0.0 <3.0.0"
1616
brick_graphql: ">=4.0.0 <5.0.0"
1717
brick_json_generators: ">=4.0.0 <5.0.0"
18-
build: ">=2.4.2 <3.0.0"
18+
build: ">=2.4.2 <2.5.0"
1919
dart_style: ">=3.0.0 <4.0.0"
2020
source_gen: ">=1.5.0 <3.0.0"
2121

packages/brick_graphql_generators/test/graphql_model_serdes_generator/test_enum_as_string.dart

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,19 @@ Future<EnumAsString> _$EnumAsStringFromGraphql(
88
}) async {
99
return EnumAsString(
1010
hat: Hat.values.byName(data['hat']),
11-
nullableHat:
12-
data['nullableHat'] == null
13-
? null
14-
: Hat.values.byName(data['nullableHat']),
15-
hats:
16-
data['hats']
17-
.whereType<String>()
18-
.map(Hat.values.byName)
19-
.toList()
20-
.cast<Hat>(),
21-
nullableHats:
22-
data['nullableHats']
23-
.whereType<String>()
24-
.map(Hat.values.byName)
25-
?.toList()
26-
.cast<Hat?>(),
11+
nullableHat: data['nullableHat'] == null
12+
? null
13+
: Hat.values.byName(data['nullableHat']),
14+
hats: data['hats']
15+
.whereType<String>()
16+
.map(Hat.values.byName)
17+
.toList()
18+
.cast<Hat>(),
19+
nullableHats: data['nullableHats']
20+
.whereType<String>()
21+
.map(Hat.values.byName)
22+
?.toList()
23+
.cast<Hat?>(),
2724
);
2825
}
2926

packages/brick_graphql_generators/test/graphql_model_serdes_generator/test_from_json_to_json.dart

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,19 @@ Future<ToFromJson> _$ToFromJsonFromGraphql(
1111
}) async {
1212
return ToFromJson(
1313
assoc: ToFromJsonAssoc.fromJson(data['assoc'] as String),
14-
assocNullable:
15-
data['assocNullable'] == null
16-
? null
17-
: ToFromJsonAssoc.fromJson(data['assocNullable'] as String),
18-
assocIterable:
19-
data['assocIterable']
20-
.map((d) => ToFromJsonAssoc.fromJson(d as String))
21-
.toList()
22-
.cast<ToFromJsonAssoc>(),
23-
assocIterableNullable:
24-
data['assocIterableNullable'] == null
25-
? null
26-
: data['assocIterableNullable']
27-
?.map((d) => ToFromJsonAssoc.fromJson(d as String))
28-
.toList()
29-
.cast<ToFromJsonAssoc>(),
14+
assocNullable: data['assocNullable'] == null
15+
? null
16+
: ToFromJsonAssoc.fromJson(data['assocNullable'] as String),
17+
assocIterable: data['assocIterable']
18+
.map((d) => ToFromJsonAssoc.fromJson(d as String))
19+
.toList()
20+
.cast<ToFromJsonAssoc>(),
21+
assocIterableNullable: data['assocIterableNullable'] == null
22+
? null
23+
: data['assocIterableNullable']
24+
?.map((d) => ToFromJsonAssoc.fromJson(d as String))
25+
.toList()
26+
.cast<ToFromJsonAssoc>(),
3027
);
3128
}
3229
@@ -39,8 +36,9 @@ Future<Map<String, dynamic>> _$ToFromJsonToGraphql(
3936
'assoc': instance.assoc.toJson(),
4037
'assocNullable': instance.assocNullable?.toJson(),
4138
'assocIterable': instance.assocIterable.map((s) => s.toJson()).toList(),
42-
'assocIterableNullable':
43-
instance.assocIterableNullable?.map((s) => s.toJson()).toList(),
39+
'assocIterableNullable': instance.assocIterableNullable
40+
?.map((s) => s.toJson())
41+
.toList(),
4442
};
4543
}
4644

packages/brick_graphql_generators/test/graphql_model_serdes_generator_test.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ class TestGenerator extends AnnotationSuperGenerator<GraphqlSerializable> {
8888
Future<void> generateExpectation(String filename, String output, {TestGenerator? generator}) async {
8989
final reader = await generateReader(filename);
9090
final generated = await (generator ?? _generator).generate(reader, MockBuildStep());
91+
92+
if (generated.trim() != output.trim()) {
93+
// ignore: avoid_print
94+
print(generated);
95+
}
96+
9197
expect(generated.trim(), output.trim());
9298
}
9399

@@ -98,5 +104,11 @@ Future<void> generateAdapterExpectation(String filename, String output) async {
98104
annotation.annotation,
99105
null,
100106
);
107+
108+
if (generated.trim() != output.trim()) {
109+
// ignore: avoid_print
110+
print(generated);
111+
}
112+
101113
expect(generated.trim(), output.trim());
102114
}

packages/brick_json_generators/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ dependencies:
1313
analyzer: ">=6.11.0 <8.0.0"
1414
brick_build: ">=4.0.0 <5.0.0"
1515
brick_core: ">=2.0.0 <3.0.0"
16-
build: ">=2.4.2 <3.0.0"
16+
build: ">=2.4.2 <2.5.0"
1717
dart_style: ">=3.0.0 <4.0.0"
1818
source_gen: ">=1.5.0 <3.0.0"
1919

packages/brick_offline_first_build/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ dependencies:
1717
brick_offline_first: ">=4.0.0 <5.0.0"
1818
brick_sqlite: ">=4.0.0 <5.0.0"
1919
brick_sqlite_generators: ">=4.0.0 <5.0.0"
20-
build: ">=2.4.2 <3.0.0"
20+
build: ">=2.4.2 <2.5.0"
2121
dart_style: ">=3.0.0 <4.0.0"
2222
logging: ">=1.0.0 <2.0.0"
2323
meta: ">=1.3.0 <2.0.0"

packages/brick_offline_first_build/test/__helpers__.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ Future<void> generateExpectation(
2020
}) async {
2121
final reader = await generateReader(filename);
2222
final generated = await (generator ?? _generator).generate(reader, MockBuildStep());
23+
24+
if (generated.trim() != output.trim()) {
25+
// ignore: avoid_print
26+
print(generated);
27+
}
28+
2329
expect(generated.trim(), output.trim());
2430
}
2531

@@ -34,6 +40,12 @@ Future<void> generateAdapterExpectation(
3440
annotation.annotation,
3541
MockBuildStep(),
3642
);
43+
44+
if (generated.trim() != output.trim()) {
45+
// ignore: avoid_print
46+
print(generated);
47+
}
48+
3749
expect(generated.trim(), output.trim());
3850
}
3951

packages/brick_offline_first_build/test/offline_first_generator/test_custom_offline_first_serdes.dart

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ Future<CustomOfflineFirstSerdes> _$CustomOfflineFirstSerdesFromTest(
88
OfflineFirstRepository? repository,
99
}) async {
1010
return CustomOfflineFirstSerdes(
11-
string:
12-
data['string'] == null ? null : Serializable.fromTest(data['string']),
11+
string: data['string'] == null
12+
? null
13+
: Serializable.fromTest(data['string']),
1314
constructorFieldNullabilityMismatch:
1415
data['constructor_field_nullability_mismatch'] as bool?,
15-
strings:
16-
data['strings'] == null
17-
? null
18-
: data['strings']
19-
?.map((c) => Serializable.fromTest(c as Map<String, dynamic>))
20-
.toList()
21-
.cast<Serializable>(),
16+
strings: data['strings'] == null
17+
? null
18+
: data['strings']
19+
?.map((c) => Serializable.fromTest(c as Map<String, dynamic>))
20+
.toList()
21+
.cast<Serializable>(),
2222
);
2323
}
2424
@@ -41,19 +41,17 @@ Future<CustomOfflineFirstSerdes> _$CustomOfflineFirstSerdesFromSqlite(
4141
OfflineFirstRepository? repository,
4242
}) async {
4343
return CustomOfflineFirstSerdes(
44-
string:
45-
data['string'] == null
46-
? null
47-
: Serializable.fromSqlite(data['string'] as int),
44+
string: data['string'] == null
45+
? null
46+
: Serializable.fromSqlite(data['string'] as int),
4847
constructorFieldNullabilityMismatch:
4948
data['constructor_field_nullability_mismatch'] == 1,
50-
strings:
51-
data['strings'] == null
52-
? null
53-
: jsonDecode(data['strings'])
54-
.map((c) => Serializable.fromSqlite(c as int))
55-
.toList()
56-
.cast<Serializable>(),
49+
strings: data['strings'] == null
50+
? null
51+
: jsonDecode(data['strings'])
52+
.map((c) => Serializable.fromSqlite(c as int))
53+
.toList()
54+
.cast<Serializable>(),
5755
)..primaryKey = data['_brick_id'] as int;
5856
}
5957

0 commit comments

Comments
 (0)