Hi, does honeysql have syntax for Postgresql ROW_NUMBER() OVER (….) ?
(hsql/format {:select [[[(keyword "row_number() over") "D"]]] :from :a})
=> [“SELECT ROW_NUMBER() OVER(?) FROM a” “D”]
There must be a better way, right? 😅
Is this close to what you want:
user=> (hsql/format {:select [[[:over [[:row_number] {:select [["D" :d]]}]]]] :from :a})
["SELECT ROW_NUMBER() OVER (SELECT ? AS d) FROM a" "D"]Yes, I just found it in the documentation. I didn’t think to look for it there if I didn’t find the question about it on slack. My mistake and thanks!
Actually - why would anyone ask if they look at the documentation first 😅
There's a lot of documentation. Folks often miss something or other.
I would also like to ask about this one.. 🙏
jsonb_path_query_array(abcd, '$."z-x-c".types.*.values.*."id"') @> '["ea1a9af7-94ec-49cc-af44-221adf46bf6f", ....]'
I construct it like this
[:jsonb_path_query_array
:abcd
[:raw "'$.\"z-x-c\".types.*.values.*.\"id\"'"]]
[:raw (format "'[%s]'" (str/join "," (map #(str "\"" % "\"") ids)))]]
The first :raw is fine, I don’t need to construct it in HoneySQL.
But what about the array in single quotes, is there some syntax for it?I'd use :inline instead of :raw since it will turn "fo\"o" into 'fo"o' so you don't need the single quotes in there.
The main issue here is that you're dealing with strings in SQL -- '...' -- rather than "syntax", so there's not much HoneySQL can do to help.
Right, no problem, thank you.