Skip to content

Commit 32a922e

Browse files
author
Ivan Dlugos
committed
generator - make sure relation fields are not tagged unsigned in the model
1 parent ab1b862 commit 32a922e

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

generator/integration-tests/relations/lib/lib.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ class C {
2525

2626
String text;
2727
C(this.text);
28-
}
28+
}

generator/lib/src/code_chunks.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,7 @@ class CodeChunks {
208208
// constructor anyway - there's no Int8List.generate() factory.
209209
fbReader = 'fb.ListReader<int>(fb.Int8Reader())';
210210
if (p.fieldIsNullable) {
211-
preLines.add(
212-
'final $valueVar = ${readFieldOrNull()};');
211+
preLines.add('final $valueVar = ${readFieldOrNull()};');
213212
return '$valueVar == null ? null : ${p.fieldType}.fromList($valueVar)';
214213
} else {
215214
return '${p.fieldType}.fromList(${readFieldNonNull('[]')})';
@@ -229,8 +228,7 @@ class CodeChunks {
229228
}
230229
if (p.fieldType == 'DateTime') {
231230
if (p.fieldIsNullable) {
232-
preLines
233-
.add('final $valueVar = ${readFieldOrNull()};');
231+
preLines.add('final $valueVar = ${readFieldOrNull()};');
234232
if (p.type == OBXPropertyType.Date) {
235233
return '$valueVar == null ? null : DateTime.fromMillisecondsSinceEpoch($valueVar)';
236234
} else if (p.type == OBXPropertyType.DateNano) {

generator/lib/src/entity_resolver.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,9 @@ class EntityResolver extends Builder {
196196
prop.relationTarget = relTargetName;
197197
prop.flags |= OBXPropertyFlags.INDEXED;
198198
prop.flags |= OBXPropertyFlags.INDEX_PARTIAL_SKIP_ZERO;
199+
200+
// IDs must not be tagged unsigned for compatibility reasons
201+
prop.flags &= ~OBXPropertyFlags.UNSIGNED;
199202
}
200203

201204
// Index and unique annotation.

0 commit comments

Comments
 (0)