-
Notifications
You must be signed in to change notification settings - Fork 374
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: Each updateFilter must have corresponding bindPlan #373
base: main
Are you sure you want to change the base?
Conversation
colFilter = acceptAllFilter | ||
} else { | ||
t.updatePlan = bindPlan{} // a new bindPlan everytime; since we cannot compare colFilter funcs | ||
t.colFilter = colFilter |
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'm a firm believer in avoiding else
at nearly all costs. Branches are really harsh on the mental stack when reading code, and else
statements are the worst (especially in go, where they can carry extra context). Can we try something more like:
if t.colFilter != nil || colFilter != nil {
t.updatePlan = bindPlan{}
}
if colFilter == nil {
colFilter = acceptAllFilter
}
t.colFilter = colFilter
@@ -26,12 +26,13 @@ type TableMap struct { | |||
SchemaName string | |||
gotype reflect.Type | |||
Columns []*ColumnMap | |||
keys []*ColumnMap | |||
keys []*ColumnMap // primary key column; can be autoIncrement |
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 don't think this comment is related to this PR.
@@ -296,7 +296,7 @@ func (m *DbMap) readStructColumns(t reflect.Type) (cols []*ColumnMap, primaryKey | |||
isPK = true | |||
case "autoincrement": | |||
isAuto = true | |||
case "notnull": | |||
case "notnull", "not null": |
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 change is not related to this PR, and it also doesn't have any tests.
Current behavior:
I set an updateFilter - then I update => works.
Now I remove the updateFilter - then I update => broken - still only the columns from previous updateFilter are updated. Reason: the bindPlan does not reflect the removal of the update filter.
I added tests, to demonstrate the fixed behavior.
Kind regards
Peter