-
Notifications
You must be signed in to change notification settings - Fork 27
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
BlackListing or WhiteListing columns for struct based inserts and updates #21
Conversation
nice feature! |
values := si.recordDescription.structMapping.GetNonAutoFieldsValues(currentRecord) | ||
if hasWB { | ||
columns, values = si.recordDescription.structMapping.GetNonAutoFieldsValuesFiltered(currentRecord, columns) | ||
if !wbColsSet { // order of old columns list and current values list may not be same so, set here: |
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.
wbColsSet
need to be set to true here.
You can add a test with BulkInsert to reveal the error (and ensure there will be no regression) :
Convey("Do executes the query using a blacklist", func() {
dummies := make([]Dummy, 0, 2)
dummy1 := Dummy{
AText: "Dummy1",
AnotherText: "Foo",
AnInteger: 12345,
ANullableString: sql.NullString{String: "Void", Valid: true},
}
dummy2 := Dummy{
AText: "Dummy2",
AnotherText: "Foo",
AnInteger: 12345,
ANullableString: sql.NullString{String: "Void", Valid: true},
}
dummies = append(dummies, dummy1, dummy2)
err := db.BulkInsert(&dummies).Blacklist("a_nullable_string").Do()
So(err, ShouldBeNil)
})
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.
That's right, it is a footprint of my struggle to preserve to match params
and values
. First tried a map for columns and values, that failed because of random ordering of maps. Later used slices for columns
and values
.
Corrected. Thanks
As you made some more changes since my last review, I'm not sure if it's finished or not (Github lack the WIP status in PR). Can I merge it ? |
Yes please! |
This PR is to blacklist or whitelist columns during struct based inserts or updates. For example:
Also added
BlacklistReset
orWhitelistReset
for struct based inserts or updates to clear lists.