Closed plexus closed 7 years ago
@camsaul: ping in case you missed this
Oh yeah. Thanks @mazameli i didn't get an email about this. I'll take a look at this @plexus
Thanks @camsaul! There are two other open PRs as well, a small one (#12) by @bandresen and a bigger one (#14) by me.
Hi @camsaul, thanks for reviewing this. Sorry for the delay, I had some other stuff I had to wrap up first.
I think I addressed your comments. Let me know if there's anything else.
Thanks @plexus, Sorry I haven't got a chance to go over this the last few days but I should have time to take a look at everything tomorrow. 👍
Inserts were being done with jdbc/insert-multi!, which internally generates the necessary SQL statements. This means HoneySQL is bypassed for inserts, and so HoneySQL features like calling SQL functions with (sql/call ,,,) are unavailable.
This patch instead makes HoneySQL generate the INSERT statements, and executes them with the lower level jdbc/db-do-prepared-return-keys. When inserting multiple rows at once it executes separate INSERT statements, rather than a single statement with multiple VALUES. This behavior is the same with jdbc/insert-multi!. It's otherwise not possible to retrieve the primary keys of the inserted rows. (This is a limitation of jdbc/db-do-prepared-return-keys, not of JDBC itself).
I've added test-cases for db/insert-many! and db/simple-insert-many!, since those were still missing, as well as an extra test case for db/insert! which demonstrates the use of an SQL function call.