Closed brahmlower closed 8 months ago
Can you add a doc test?
Oh absolutely! In hindsight it's pretty obvious that I should have included that in the first place 😅 I'll start working on that now, should have it pushed relatively soon
Mkay I've added the doctest example. I just copied and updated the example used for conditionals
for the sake of consistency, but I'm happy to make changes if you'd prefer something different 👍
Hey @tyt2y3 👋 I just wanted to check in to see if there were any other concerns with this PR?
Hi! Just came back. Happy new year!
Thank you everyone for the contribution! This feature is now available in the latest release. Now is a good time to upgrade! Your participation is what makes us unique; your adoption is what drives us forward. You can support SeaQL 🌊 by starring our repos, sharing our libraries and becoming a sponsor ⭐.
Hey thanks for merging this yesterday! Didn't intend to rush ya, so sorry about that- hope you had a good break, and happy new year to you too! 🥳
Heya! 👋 Thanks for all your work on the library- I've really enjoyed working with it! I ran into a quality of life shortcoming with the API around the
SelectStatement
builder: I wanted a clean way of building a portion of the query in another function, similar to the pattern used by theconditions
method, but without the actual conditional part 😁PR Info
New Features
[ ] Added
apply
method toSelectStatement
for constructing part of the statement from another functionThis new method is essentially a shorthand form of using the
conditions
function with a hardcoded value:This is useful in cases where multiple queries have the same "core" expressions, like when gathering results vs counting total query size (for pagination) on a query with joins, conditional where clauses, and groupings:
This is somewhat contrived example to keep it as simple as possible. For my use case, the function used to build common expressions on the query is a struct method that's referencing it's own internal state to apply the conditional filters:
Bug Fixes
None
Breaking Changes
None
Changes
None as of initial authorship, however the
SelectStatement::conditions
method could be updated to call out to the newapply
function if so desired, but it'd be a little pedantic: