I have wrote a stored proc :-)
Hi all, I’m trying to use honeysql to help me write an upsert command in psql
[INSERT INTO import.spaces (id, import_timestamp, record) VALUES (?, ?, ()), (?, ?, ()), (?, ?, ()) ON CONFLICT (id) DO UPDATE SET record = EXCLUDED.record 43b199b9-0c85-4279-97a4-34bc9abbc653 #inst "2020-01-06T18:47:22.000000000-00:00" fc6b6471-c779-403b-88b6-09b3cdb4cad2 #inst "2020-01-06T18:47:22.000000000-00:00" d02e9a44-751c-45aa-a73b-5c673b79f3ac #inst "2020-01-06T18:47:22.000000000-00:00"]
When trying to execute this command, I get a syntax error of ERROR: syntax error at or near ")"
Anyone have any ideas as to why this might be?
(-> (insert-into table)
(values data-vec)
(upsert (-> (on-conflict :id)
(do-update-set :record)))
hsql/format)
here’s the actual hsql code
VALUES (?, ?, ())
seems strange, the last element ()
the vector is something like:
(def multi-entry
[{:id (uuid)
:import_timestamp (now)
:record {:foo "one"}}
{:id (uuid)
:import_timestamp (now)
:record {:foo "two"}}
{:id (uuid)
:import_timestamp (now)
:record {:foo "three"}}])
is it because that third argument is another hash map?
It could be, maybe hsql doesn’t know how to parameterize it and cannot lift it as parameter
bummer
maybe there is some other way for me to format it so it can work
I found if I convert the :record
or in my case JSON column into a json str, it works
so it doesn’t have to read the nested hashmap