Fork me on GitHub

Hi. I'm using java.jdbc on my work. I have two questions. 1) shoud I use :multi? option, if I want to insert some records and using :return-keys option? A: (execute! db-spec ["insert into foo (x) values (?), (?)" "x" "y"] {:return-keys true}) vs B: (execute! db-spec ["insert into foo (x) values (?)" ["x"] ["y"]] {:return-keys true :multi? true}) I know, these are differet results. My expectation is B's result, however I want to use A's query. Because Honey SQL don't support :multi? option and A is fast. 2) Why :return-keys should not work correctlly. foo table has two columns, x and y, and I just needs x column. So, I wrote the code like this. (execute! db-spec ["insert into foo (x, y) values (?, ?)" "x" "y"] {:return-keys ["x"]}) But, I got a result as {:x "x", :y "y"}. If I use prepare-statement directly, it works. Is this a correct behavior?


execute! doesn't have a :return-keys option, which is why it has no effect when you pass one in


the only options execute! takes are :multi? and :transaction?


have you tried using insert-rows! ? if I recall that just returns a collection of the inserted keys


what version of java.jdbc are you using?


I was looking at an old check I had, which is why I said execute! doesn't take that option, if you are seeing it behave as if execute! doesn't have that option maybe you are using an old version where it doesn't


You mean, insert-multi! ? I don't want to use this. Because I'm using Honey SQL and HugSQL and so on.


Ah, java.jdbc 0.7.5


do you have an example of prepare-statement giving you the behavior you want?


from what I can see, the behavior of returning keys is largely determined by the underlying jdbc driver


execute! just passes the result-set to a function that generates a seq of maps from it


come to think of it, where are the generated keys in your example?