-
-
Notifications
You must be signed in to change notification settings - Fork 341
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
[jdbi3] Support optional clauses in SQL for bound optional parameters. #381
Comments
YMMV, but IMO this shouldn't be a design goal. First, this is the sort of thing that the StringTemplate statement locator does very well. While StringTemplate does not know about Using StringTemplate, the example provided is a straightforward as:
No, it's not as concise, but what it loses in brevity it gains in power; I can reuse the first part of the query in multiple variations, and have them be consistent, and I get protection from my own errors of forgetting to bind or accidentally binding in the wrong use case. |
I too am somewhat "meh" on this feature. Another option that is not as concise but doesn't require any additional support:
Maybe if you really want it, it's appropriate as a different standalone statement rewriter? |
The main value I was after was the ability to mix and match filters on queries, e.g. on a search form with multiple optional fields. However as @stevenschlansker pointed out, this is already possible within the SQL syntax:
Closing. |
But how optimised this query is? Will there be an extra condition check for each |
There are lots of scenarios where you want to include/exclude a fragment from the SQL statement depending on what is bound to a particular parameter:
The
{ id => WHERE id = :id }
is certainly up for debate--we'd have to ensure that whatever syntax we picked didn't conflict with valid SQL tokens.This could be implemented in our default statement rewriters.
The text was updated successfully, but these errors were encountered: