sqlboiler
sqlboiler copied to clipboard
WhereIn helper not generated for nullable primitives
As the title says.
In sql, the WHERE ... IN
clause is equally valid for nullable and non-nullable types.
The templates generate WhereIn helper methods for primitive types:
https://github.com/volatiletech/sqlboiler/blob/fad098aa2ba38220c0727620b7ea665983aec26e/templates/00_struct.go.tpl#L56
but since isPrimitive()
(correctly) doesn't consider null types primitives, these helpers are not generated for nullable types (e.g. null.String
)
https://github.com/volatiletech/sqlboiler/blob/a11ea0b016bdf0dda356324466de11eb31ee63e5/boilingcore/text_helpers.go#L128
This would have been a trivial change after https://github.com/volatiletech/sqlboiler/pull/575, but now it probably means adding a function to the text helpers to translate between null types and their primitive counterparts.
I'm willing to cut a PR if this is something you're interested in having.
Are you sure this is a problem? I'm almost positive I've used where helpers in the past with nullable primitives... You don't mention an sqlboiler version number so it's hard to tell.
Hmm I am using version 3.7.1, but from looking at the code I think it might still be an issue, unless I missed something.
I'll try to reproduce on the latest version.
I can confirm that IN/NIN whereHelpers are not created for nullable types in 4.4.
Fixed by https://github.com/volatiletech/sqlboiler/pull/1083