-
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
Fix the returned schema object for broken views #12713
Fix the returned schema object for broken views #12713
Conversation
The logic added in vitessio#12675 has a small issue. When a view is found that has an error, it's not present anymore when a subsequent `.ToSQL()` call happens, so it looks like the view disappears. We should never have a view disappear since that could potentially break things and lead to unexpected results. Signed-off-by: Dirkjan Bussink <d.bussink@gmail.com>
} | ||
return schema, nil | ||
err := schema.normalize() | ||
return schema, err |
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.
Small equivalent simplification here.
@@ -309,16 +307,18 @@ func (s *Schema) normalize() error { | |||
// - two or more views have a circular dependency | |||
for _, t := range s.tables { | |||
if _, ok := dependencyLevels[t.Name()]; !ok { | |||
// We _know_ that in this iteration, at least one view is found unassigned a dependency level. | |||
// We _know_ that in this iteration, at least one foreign key is not found. |
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.
comment was wrong here as well.
errs = errors.Join(errs, &ViewDependencyUnresolvedError{View: v.ViewName.Name.String()}) | ||
// We still add it so it shows up in the output if that is used for anything. | ||
s.sorted = append(s.sorted, v) |
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.
Fixed the logic and the comment.
The logic added in #12675 has a small issue. When a view is found that has an error, it's not present anymore when a subsequent
.ToSQL()
call happens, so it looks like the view disappears.We should never have a view disappear since that could potentially break things and lead to unexpected results.
Related Issue(s)
Issue introduced in #12675
Checklist