mirror of
https://github.com/immich-app/drift.git
synced 2026-09-30 13:22:57 +08:00
Improve error message for schema difference
This commit is contained in:
@@ -166,7 +166,7 @@ class FindSchemaDifferences {
|
||||
|
||||
if (refType != actType) {
|
||||
return FoundDifference(
|
||||
'Different types: ${ref.typeName} and ${act.typeName}');
|
||||
'Different types: Expected ${ref.typeName}, got ${act.typeName}');
|
||||
}
|
||||
|
||||
try {
|
||||
@@ -174,19 +174,20 @@ class FindSchemaDifferences {
|
||||
} catch (e) {
|
||||
final firstSpan = ref.constraints.spanOrNull?.text ?? '';
|
||||
final secondSpan = act.constraints.spanOrNull?.text ?? '';
|
||||
return FoundDifference('Not equal: `$firstSpan` and `$secondSpan`');
|
||||
return FoundDifference(
|
||||
'Not equal: `$firstSpan` (expected) and `$secondSpan` (actual)');
|
||||
}
|
||||
|
||||
return const Success();
|
||||
}
|
||||
|
||||
CompareResult _compareByAst(AstNode a, AstNode b) {
|
||||
CompareResult _compareByAst(AstNode reference, AstNode actual) {
|
||||
try {
|
||||
enforceEqual(a, b);
|
||||
enforceEqual(reference, actual);
|
||||
return const Success();
|
||||
} catch (e) {
|
||||
return FoundDifference(
|
||||
'Not equal: `${a.span?.text}` and `${b.span?.text}`');
|
||||
return FoundDifference('Not equal: Expected `${reference.span?.text}`, '
|
||||
'got `${actual.span?.text}`');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ void main() {
|
||||
expect(result, hasChanges);
|
||||
expect(
|
||||
result.describe(),
|
||||
contains('Different types: TEXT and INTEGER'),
|
||||
contains('Different types: Expected TEXT, got INTEGER'),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -83,7 +83,8 @@ void main() {
|
||||
expect(result, hasChanges);
|
||||
expect(
|
||||
result.describe(),
|
||||
contains('Not equal: `PRIMARY KEY NOT NULL` and ``'),
|
||||
contains(
|
||||
'Not equal: `PRIMARY KEY NOT NULL` (expected) and `` (actual)'),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user