Skip to content

Commit f4f2481

Browse files
committed
retain and expose Model.id with _unmappedFieldsToObject
1 parent 383d78f commit f4f2481

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

app/lib/shared/integrity.dart

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,9 @@ class IntegrityChecker {
4848
final DatastoreDB _db;
4949
final int _concurrency;
5050

51-
final _unmappedFields = <String>{};
51+
/// Maps an unmapped field in the form of `<ClassName>.<fieldName>` to an
52+
/// object identifier (usually the `id` value of the entity).
53+
final _unmappedFieldsToObject = <String, String>{};
5254
final _userToOauth = <String, String?>{};
5355
final _oauthToUser = <String, String>{};
5456
final _deletedUsers = <String>{};
@@ -103,10 +105,10 @@ class IntegrityChecker {
103105
yield* _checkModerationCases();
104106
yield* _reportPubspecVersionIssues();
105107

106-
if (_unmappedFields.isNotEmpty) {
107-
for (final field in _unmappedFields) {
108-
if (_allowedUnmappedFields.contains(field)) continue;
109-
yield 'Unmapped field found: $field.';
108+
if (_unmappedFieldsToObject.isNotEmpty) {
109+
for (final entry in _unmappedFieldsToObject.entries) {
110+
if (_allowedUnmappedFields.contains(entry.key)) continue;
111+
yield 'Unmapped field found: "${entry.key}" on entity "${entry.value}".';
110112
}
111113
}
112114
} finally {
@@ -927,8 +929,9 @@ class IntegrityChecker {
927929
void _updateUnmappedFields(Model m) {
928930
if (m is ExpandoModel && m.additionalProperties.isNotEmpty) {
929931
for (final key in m.additionalProperties.keys) {
930-
final field = [m.runtimeType.toString(), key].join('.');
931-
_unmappedFields.add(field);
932+
final qualifiedField = [m.runtimeType.toString(), key].join('.');
933+
if (_unmappedFieldsToObject.containsKey(qualifiedField)) continue;
934+
_unmappedFieldsToObject[qualifiedField] = m.id.toString();
932935
}
933936
}
934937
}

0 commit comments

Comments
 (0)