-
-
Notifications
You must be signed in to change notification settings - Fork 8
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
support filtering table definitions #39
Conversation
Codecov ReportBase: 100.00% // Head: 100.00% // No change to project coverage 👍
Additional details and impacted files@@ Coverage Diff @@
## main #39 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 11 11
Lines 614 625 +11
=========================================
+ Hits 614 625 +11
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
builder/table.go
Outdated
result := []rel.TableDefinition{} | ||
|
||
for _, def := range table.Definitions { | ||
if t.DefinitionFilter == nil || t.DefinitionFilter(table, def) { |
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.
better to move t.DefinitionFilter == nil
as early return before calling this loop
if t.DefinitionFilter == nil {
return table.Definitions
}
table: rel.Table{ | ||
Op: rel.SchemaAlter, | ||
Name: "columns", | ||
Definitions: []rel.TableDefinition{ |
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.
should we just filter out silently like this? or do you think it's better to print some log? 🤔
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.
It would be better to have some way to inform users.
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.
It may be sufficient to output logs in the DefinitionFilter
like this
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.
agree, something like that should be sufficient
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.
Hi @youpy, could you add the log as well?
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.
Sorry, I just added.
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 thought the log will be inside definitions functions?
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.
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.
Oh, I misunderstood
added (53e002a)
Thank you for this PR |
Yes, but I haven't written any code yet |
builder/table.go
Outdated
result = append(result, def) | ||
} else { | ||
log.Print("[REL] An unsupported table definition has been excluded") | ||
log.Print("[REL] An unsupported table definition has been excluded: " + reason) |
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.
won't it be simpler if we just use: log.Printf("[REL] ....: %T", def)
?
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.
LGTM, Thank you
please use sql@master |
Added a mechanism to exclude unsupported table definitions, example for use with sqlite3 adapters that do not support
ADD CONSTRAINT
when changing the table schema.