Fork me on GitHub
#honeysql
<
2024-05-15
>
Bailey Kocin15:05:06

I do not remember what the tuple comparison is called but is there a builtin way (wihtout using raw ) to do a 2-tuple comparison in a WHERE clause? So for something like this

WHERE (time, uuid) > (val1, val2)
I have tried
[:raw (format "((time, uuid) > (%s, %s))" datetime uuid)]
But is there a better way?

Bailey Kocin15:05:56

I see this is called a composite and I can do something like

(hh/where [:> [:composite :col1 :col2] [value1 value2]) 
The value syntax is weird to me so if someone could explain that....

p-himik15:05:09

Have you tried searching for :composite on the HoneySQL docs website?

Bailey Kocin15:05:59

I did not know what I was looking for but now that I found it I can look!

seancorfield05:05:14

@U05NZDGDYG3 Is there something I can do to make this easier to find in the documentation? FWIW, I went to the cljdoc documentation, and typed tuple in the search box -- and this is the first result: https://cljdoc.org/d/com.github.seancorfield/honeysql/2.6.1126/doc/getting-started/general-reference#tuples-and-composite-values -- can I clarify how that section would apply to what you were trying to do?

Bailey Kocin13:05:17

I guess the real problem here was I did not know what I was looking for? I probably should have asked in a SQL chat to be honest. So that is my bad! Searching for "SQL tuple expressions" was not giving me the name "composite" so I did not know what to call it

seancorfield16:05:41

I just used the word from your original question here to see if it was in the docs...