java.jdbc

Insert! without transaction doesn't work on Postgres

Details

  • Type: Defect Defect
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Completed
  • Affects Version/s: None
  • Fix Version/s: None
  • Component/s: None
  • Labels:
    None
  • Environment:
    Postgres 9.4.7

Description

When insert! is run outside of transaction it is not commited when running on Postgres.
Insert! should by default automatically run the commands in transactions.

This problem is probably not seen in current tests as default test databases automatically commit single commands.

I'm yet to reproduce this using unit tests due to JDBC-127, but I can reproduce this in a application.

In 0.5.5 (https://github.com/clojure/java.jdbc/commit/310781429225b614cab01256f3adce54917644aa) extract-transaction? was removed and default :transaction? value was moved to insert!. Later, in 0.5.6 (https://github.com/clojure/java.jdbc/commit/1928ff4d627243c9d2e0bf309a8b4f965f5034d3) insert! was rewriten. :transaction? check was moved to insert-cols! and insert-rows! but the default value was lost.

I attached a patch that adds the default value to insert-cols! and insert-rows. But I think it would be a good idea to wait until test issues (JDBC-127) have been fixed before merging this, so that this problem and solution can be validated using tests.

Activity

Hide
Sean Corfield added a comment -

Good catch on this!

I have not been able to reproduce this in a test case yet but I can see by inspection that you're right about the loss of transaction by default. I'm surprised I haven't run into this in all my other testing (on MySQL).

Show
Sean Corfield added a comment - Good catch on this! I have not been able to reproduce this in a test case yet but I can see by inspection that you're right about the loss of transaction by default. I'm surprised I haven't run into this in all my other testing (on MySQL).
Hide
Sean Corfield added a comment -

Fixed in 0.6.1 which should be on Maven Central tonight!

Show
Sean Corfield added a comment - Fixed in 0.6.1 which should be on Maven Central tonight!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: