You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Right now, each type of select is considered a completely different clause so "merging" them simply doesn't work. You can merge select with itself. You can merge select-distinct-on with itself (since #372 got fixed). You can merge select-distinct with itself. You cannot merge select-top or select-distinct-top with itself (because the first argument is "special" and merging just concatenates arguments).
But the question is really: what should merging those types of selects really do?
if you merge select-distinct and select, the result could safely be select-distinct with all the columns merged
similarly, if you merge select-top and select, the result could safely be select-top with its first argument and then all the columns merged
similarly, for select-top and select-distinct, the result could safely be :select-distinct-top with the first arg from select-top and then all the columns merged
What about the other combinations? What should select-top merged with select-top do? An error? Overwrite one top expression with the other silently?
The text was updated successfully, but these errors were encountered:
I'm beginning to wonder if having a generic :select+ might be a good idea, where the first argument is a sequence of qualifiers to use, and merging it could handle the logic in some sort of intuitive way. That wouldn't address the select-distinct/select merge, although perhaps select+ could check if there's a select in the DSL and "upgrade" it to a select+?
I was running into this problem today:
I have a function that takes a sql query as input. I need to append something to the select in both cases, but one is using :select and the other is using a :select-distinct-on.
Of course I could look into the query to see what type of select it uses.
Being a bit of an edge-case, an (append-to-select query :column-name) type of function might just be enough? We are just manipulating datastructures here.
That's a different problem. This issue is about the helper functions specifically and what should happen if you use one of the select... helpers to merge something into an existing query that was built with a different select... helper.
In your case, your function could either check specifically for :select or :select-distinct-on and append to the argument of whichever it finds. But the general case could have symbols rather than keywords and could be any of the selection DSL clauses which have different semantics for their arguments.
Right now, each type of select is considered a completely different clause so "merging" them simply doesn't work. You can merge
select
with itself. You can mergeselect-distinct-on
with itself (since #372 got fixed). You can mergeselect-distinct
with itself. You cannot mergeselect-top
orselect-distinct-top
with itself (because the first argument is "special" and merging just concatenates arguments).But the question is really: what should merging those types of selects really do?
select-distinct
andselect
, the result could safely beselect-distinct
with all the columns mergedselect-top
andselect
, the result could safely beselect-top
with its first argument and then all the columns mergedselect-top
andselect-distinct
, the result could safely be:select-distinct-top
with the first arg fromselect-top
and then all the columns mergedWhat about the other combinations? What should
select-top
merged withselect-top
do? An error? Overwrite one top expression with the other silently?The text was updated successfully, but these errors were encountered: