sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

WhereIn helper not generated for nullable primitives

Open fdegiuli opened this issue 3 years ago • 3 comments

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.

fdegiuli avatar Oct 22 '20 06:10 fdegiuli

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.

aarondl avatar Nov 04 '20 04:11 aarondl

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.

fdegiuli avatar Jan 13 '21 20:01 fdegiuli

I can confirm that IN/NIN whereHelpers are not created for nullable types in 4.4.

bbarcklay avatar Feb 16 '21 16:02 bbarcklay

Fixed by https://github.com/volatiletech/sqlboiler/pull/1083

fdegiuli avatar Sep 23 '22 18:09 fdegiuli