-
Notifications
You must be signed in to change notification settings - Fork 375
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this comment is related to this PR. |
||
indexes []*IndexMap | ||
uniqueTogether [][]string | ||
version *ColumnMap | ||
insertPlan bindPlan | ||
updatePlan bindPlan | ||
colFilter ColumnFilter // different column filters lead to different updatePlans | ||
deletePlan bindPlan | ||
getPlan bindPlan | ||
dbmap *DbMap | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -169,8 +169,16 @@ func (t *TableMap) bindInsert(elem reflect.Value) (bindInstance, error) { | |
} | ||
|
||
func (t *TableMap) bindUpdate(elem reflect.Value, colFilter ColumnFilter) (bindInstance, error) { | ||
|
||
if colFilter == nil { | ||
if t.colFilter != nil { | ||
t.updatePlan = bindPlan{} | ||
} | ||
t.colFilter = nil | ||
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 commentThe reason will be displayed to describe this comment to others. Learn more. I'm a firm believer in avoiding if t.colFilter != nil || colFilter != nil {
t.updatePlan = bindPlan{}
}
if colFilter == nil {
colFilter = acceptAllFilter
}
t.colFilter = colFilter |
||
} | ||
|
||
plan := &t.updatePlan | ||
|
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.