sqlboiler icon indicating copy to clipboard operation
sqlboiler copied to clipboard

Generate IN/NIN whereHelpers for nullable types

Open fdegiuli opened this issue 2 years ago • 6 comments

Enables IN/NIN whereHelper function generation for nullable types addressing issue #851. Based on #910.

The generated helpers take the underlying primitive types, so that a null.String column would generate a function with signature IN(slice []string) qm.QueryMod

I implemented it this way (instead of accepting nullable values) for a few reasons:

  1. The code is much simpler
  2. I imagine most people aren't using null.* to construct these clauses currently
  3. A NULL in an IN clause is meaningless in SQL anyway, as it does not affect the result

fdegiuli avatar Feb 11 '22 18:02 fdegiuli

@stephenafamo do you need anything from me in order to merge this PR? As far as I can tell there are no existing tests for this part of the code generation, but I did generate the test schema and made sure that everything worked as expected. It doesn't seem worth testing the text helpers since the test for a function that simple would look exactly like the original function anyway, but I'm happy to add some if you want.

fdegiuli avatar Apr 29 '22 15:04 fdegiuli

I haven't had time to manually check it. There was also some discussion about using a potential null/v9 package which would be a breaking change in it self because of the conversation about null/value/set.

Basically, a mix between testing it and making sure there are no breaking changes.

stephenafamo avatar Apr 29 '22 16:04 stephenafamo

+1 for this, would be really great to have

razor-1 avatar Jul 09 '22 00:07 razor-1

I haven't had time to manually check it. There was also some discussion about using a potential null/v9 package which would be a breaking change in it self because of the conversation about null/value/set. Basically, a mix between testing it and making sure there are no breaking changes.

@stephenafamo is there a way we can help you test it if you're short on time?

Rosswell avatar Aug 10 '22 18:08 Rosswell

Really anyone just using the branch and confirming that it works and doesn't introduce any breaking changes.

stephenafamo avatar Aug 10 '22 18:08 stephenafamo

I have included this into my fork and it works fine for my use case.

razor-1 avatar Aug 10 '22 18:08 razor-1

@fdegiuli kindly fix the merge conflicts so I can merge this

stephenafamo avatar Aug 14 '22 00:08 stephenafamo

Done. I also updated a function name in light of the changes in the master branch. Thanks for the ping

On Sat, Aug 13, 2022, 5:47 PM Stephen Afam-Osemene @.***> wrote:

@fdegiuli https://github.com/fdegiuli kindly fix the merge conflicts so I can merge this

— Reply to this email directly, view it on GitHub https://github.com/volatiletech/sqlboiler/pull/1083#issuecomment-1214257976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAHCYILNPH2T3ABBBLG3E4LVZA62TANCNFSM5OE732SA . You are receiving this because you were mentioned.Message ID: @.***>

fdegiuli avatar Aug 16 '22 00:08 fdegiuli

@stephenafamo any hope if this can be pushed in a v4 release, kind of a blocker in a project ?

lallenfrancisl avatar Aug 21 '22 14:08 lallenfrancisl

I'll tag a release within the next week.

stephenafamo avatar Aug 21 '22 14:08 stephenafamo