-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
schemadiff: pursue foreign key errors and proceed to build schema #14705
schemadiff: pursue foreign key errors and proceed to build schema #14705
Conversation
Signed-off-by: Shlomi Noach <[email protected]>
Signed-off-by: Shlomi Noach <[email protected]>
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great!
@@ -241,10 +253,12 @@ func (s *Schema) normalize() error { | |||
} | |||
referencedEntity, ok := s.named[referencedTableName] | |||
if !ok { | |||
return &ForeignKeyNonexistentReferencedTableError{Table: name, ReferencedTable: referencedTableName} | |||
errs = errors.Join(errs, addEntityFkError(t, &ForeignKeyNonexistentReferencedTableError{Table: name, ReferencedTable: referencedTableName})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was going to ask if we wanted to add/join nil errors as well, but then saw the docs: https://pkg.go.dev/errors#Join :-)
…tessio#14705) Signed-off-by: Shlomi Noach <[email protected]>
Description
When parsing/reading a
Schema
object, we now pursue reading and mapping all tables, even if we hit foreign key definition errors. We take note and aggregate all errors, and at the end we still list all input tables, whether they do have errors or not.Normally, when the caller of e.g.
s, err := NewSchemaFromEntities(...)
gets a non nilerr
, they bail out. But it is also possible for them to unwrap the list of errors, or even pry open the schema (if non-nil) and read the list of whatever tables they can find.Related Issue(s)
Checklist