Skip to content

Commit 9cc8daf

Browse files
committed
+Critical bugfix
1 parent 1eb9a68 commit 9cc8daf

File tree

4 files changed

+25
-41
lines changed

4 files changed

+25
-41
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,4 @@ If you're enjoying this package and find it valuable, consider showing your appr
4949
## License
5050

5151
This project is released under the [MIT License](https://raw.githubusercontent.com/dev-cetera/df_generate_dart_models_core/main/LICENSE). See [LICENSE](https://raw.githubusercontent.com/dev-cetera/df_generate_dart_models_core/main/LICENSE) for more information.
52+

lib/src/_utils/dart_from_record_on_dart_object_x.dart

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
3232
/// Returns `fieldName` property from [dartObj] if it matches the structure of
3333
/// [TFieldRecord] or `null`.
3434
List<String>? fieldPathFromRecord() {
35-
return _rawFieldPathFromRecord()
36-
?.map((e) => e.replaceAll('?', ''))
37-
.toList();
35+
return _rawFieldPathFromRecord()?.map((e) => e.replaceAll('?', '')).toList();
3836
}
3937

4038
List<String>? _rawFieldPathFromRecord() {
@@ -50,24 +48,20 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
5048
String? fieldTypeFromRecord() {
5149
final raw = _rawFieldTypeFromRecord();
5250
if (raw != null) {
53-
return raw.endsWith('?') ? raw.substring(0, raw.length - 1) : raw;
51+
return raw.endsWith('?') || raw.endsWith('*') ? raw.substring(0, raw.length - 1) : raw;
5452
}
5553
return null;
5654
}
5755

5856
String? _rawFieldTypeFromRecord() {
5957
final a = dartObj.getField('\$2')?.toStringValue() as String?;
6058
final b =
61-
dartObj.getField('\$2')?.toTypeValue()?.getDisplayString() as String?;
62-
final c =
63-
dartObj.getField(FieldModelFieldNames.fieldType)?.toStringValue()
64-
as String?;
65-
final d =
66-
dartObj
67-
.getField(FieldModelFieldNames.fieldType)
68-
?.toTypeValue()
69-
?.getDisplayString()
70-
as String?;
59+
dartObj.getField('\$2')?.toTypeValue()?.getDisplayString(withNullability: true) as String?;
60+
final c = dartObj.getField(FieldModelFieldNames.fieldType)?.toStringValue() as String?;
61+
final d = dartObj
62+
.getField(FieldModelFieldNames.fieldType)
63+
?.toTypeValue()
64+
?.getDisplayString(withNullability: true) as String?;
7165
return a ?? b ?? c ?? d;
7266
}
7367

@@ -78,8 +72,7 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
7872
return false;
7973
}
8074

81-
final a =
82-
dartObj.getField(FieldModelFieldNames.nullable)?.toBoolValue() as bool?;
75+
final a = dartObj.getField(FieldModelFieldNames.nullable)?.toBoolValue() as bool?;
8376
final b = dartObj.getField('\$3')?.toBoolValue() as bool?;
8477
final c = _rawFieldPathFromRecord()?.any((e) => e.contains('?'));
8578
final d = _rawFieldTypeFromRecord()?.endsWith('?');
@@ -89,32 +82,25 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
8982
/// Returns the `children` property from [dartObj] if it matches the structure of
9083
/// [TFieldRecord] or `null`.
9184
List<Map<String, dynamic>>? childrenFromRecord() {
92-
final a =
93-
dartObj
94-
.getField(FieldModelFieldNames.children)
95-
?.toListValue()
96-
?.map(
97-
(e) => e.toMapValue()!.map(
98-
(k, v) => MapEntry(k!.toStringValue()!, dartObjToObject(v)),
99-
),
100-
)
101-
as Iterable?;
85+
final a = dartObj.getField(FieldModelFieldNames.children)?.toListValue()?.map(
86+
(e) => e.toMapValue()!.map(
87+
(k, v) => MapEntry(k!.toStringValue()!, dartObjToObject(v)),
88+
),
89+
) as Iterable?;
10290
final b = a?.map((e) => (e as Map).cast<String, dynamic>()).toList();
10391
return b;
10492
}
10593

10694
/// Returns the `primaryKey` property from [dartObj] if it matches the structure
10795
/// of [TFieldRecord] or `null`.
10896
bool? primaryKeyFromRecord() {
109-
return dartObj.getField(FieldModelFieldNames.primaryKey)?.toBoolValue()
110-
as bool?;
97+
return dartObj.getField(FieldModelFieldNames.primaryKey)?.toBoolValue() as bool?;
11198
}
11299

113100
/// Returns the `foreignKey` property from [dartObj] if it matches the
114101
/// structure of [TFieldRecord] or `null`.
115102
bool? foreignKeyFromRecord() {
116-
return dartObj.getField(FieldModelFieldNames.foreignKey)?.toBoolValue()
117-
as bool?;
103+
return dartObj.getField(FieldModelFieldNames.foreignKey)?.toBoolValue() as bool?;
118104
}
119105

120106
/// Retrieves the `fallback` property from this `DartObject` if it matches
@@ -127,7 +113,6 @@ extension type DartFromRecordOnDartObjectX(_DartObject dartObj) {
127113
/// Returns the `description` property from [dartObj] record if it matches the
128114
/// structure of [TFieldRecord] or `null`.
129115
String? descriptionFromRecord() {
130-
return dartObj.getField(FieldModelFieldNames.description)?.toStringValue()
131-
as String?;
116+
return dartObj.getField(FieldModelFieldNames.description)?.toStringValue() as String?;
132117
}
133118
}

lib/src/_utils/dart_obj_to_string_list.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,11 @@ List<String>? dartObjToStringList(dynamic dartObj) {
1717
if (a != null) {
1818
return [a];
1919
}
20-
final b =
21-
dartObj
22-
?.toListValue()
23-
?.map((e) => e.toStringValue())
24-
.where((e) => e != null)
25-
.map((e) => e!)
26-
as Iterable?;
20+
final b = dartObj
21+
?.toListValue()
22+
?.map((e) => e.toStringValue())
23+
.where((e) => e != null)
24+
.map((e) => e!) as Iterable?;
2725

2826
final c = b?.map((e) => e.toString()).toList();
2927
return c;

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ repository: https://github.com/robmllze/df_generate_dart_models_core
1616
funding:
1717
- https://www.buymeacoffee.com/dev_cetera
1818
description: A package that provides core dependencies for models generated with df_generate_dart_models.
19-
version: 0.9.18
19+
version: 0.9.19
2020
topics:
2121
- build-runner
2222
- cli
@@ -35,7 +35,7 @@ dependencies:
3535
df_collection: ^0.9.3
3636
df_string: ^0.2.5
3737
df_type: ^0.12.3
38-
df_gen_core: ^0.6.12
38+
df_gen_core: ^0.6.13
3939
equatable: ^2.0.7
4040

4141
## -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)