norm icon indicating copy to clipboard operation
norm copied to clipboard

RETURNING BUG is back

Open ZZerog opened this issue 6 years ago • 1 comments

Hi, RETURNING * bug in Postgres driver is back.

Try add TRIGGER.

CREATE TRIGGER <trigger_name>AFTER INSERT OR DELETE OR UPDATE ON <table_name> FOR EACH ROW EXECUTE PROCEDURE <function_name> ()

the error: Caused by: org.postgresql.util.PSQLException: ERROR: syntax error at or near "RETURNING"

My opinion is get back the hack in the execute() method. Something as:

String lowerSql = sql.toLowerCase();
if (lowerSql.contains("create trigger")) { //better regex
	state = localCon.prepareStatement(sql);
} else {
	state = localCon.prepareStatement(sql, Statement.RETURN_GENERATED_KEYS);
}

norm - 0.8.3 postgresql - 42.2.5

ZZerog avatar May 14 '19 08:05 ZZerog

I've done a general rewrite of generated key handling. It's in the master branch. Have a look. Bottom line: RETURN_GENERATED_KEYS is never specified unless you call the new method .generatedKeyReceiver() or insert(). Let me know if it works and I'll do a release.

ccleve avatar May 20 '19 22:05 ccleve