I’m new to clojure. Have been playing with jdbc using hsqldb.
Did this function to update table “persona” where the field “cedula” is the primary key
(defn update [cedula x]
(sql/with-connection common/database
(sql/update-values :persona
["cedula=?" cedula] x)))
Ran this in REPL
(per/update 111 {:cedula 122 :nombre "Raul" :cargo "mm"})
But after that if I go to the .log file in the DB I see that it does a delete and then an insert.
/*C15*/SET SCHEMA PUBLIC
CONNECT USER SA
SET AUTOCOMMIT FALSE
DELETE FROM PERSONA WHERE CEDULA=111
INSERT INTO PERSONA VALUES(122,'Raul','mm')
COMMIT
SET AUTOCOMMIT TRUE
DISCONNECT
Is that normal?
This is the code for
update-values:As you can see, there’s absolutely no way it will generate anything but a UPDATE, as it ought to. So what’s actually happening?
From the HSQLDB docs:
So the HSQLDB log is simply writing a DELETE and INSERT, even though the query being executed is really an UPDATE.