kostafey / ejc-sql

Emacs SQL client uses Clojure JDBC.
278 stars 29 forks source link

Transaction rollback not working #167

Open sienic opened 2 years ago

sienic commented 2 years ago

Sometimes I want to test a query on my dataset, and rollback after inspecting its results. Unfortunately, the following query when executed with ejc-sql, does not rollback the transaction.

Could you point me if this a bug, misusage ~from~ of the library, or simply a desired outcome? If this is a bug, I am happy to investigate and provide a solution, but I want to get first your thoughts on this.

Thanks.

Steps to reproduce:

(postgres example)

CREATE TABLE test (id BIGINT, field VARCHAR);
INSERT INTO test(id, field) VALUES (1, NULL);
/
BEGIN;
UPDATE test SET field = 1234 WHERE id = 1;
SELECT field FROM test WHERE id = 1; -- returns 1234
ROLLBACK;
SELECT * FROM test WHERE id = 1; -- returns 1234, whereas it should return null
/
sincebyte commented 2 years ago

Maybe case every single statment be executed within an independent transaction