LauJensen / clojureql

ClojureQL is superior SQL integration for Clojure
https://clojureql.sabrecms.com
Eclipse Public License 1.0
285 stars 39 forks source link

Return id as meta data fix #83

Closed l0st3d closed 12 years ago

l0st3d commented 13 years ago

Mysql threw an SQLException when calling conj! with this message: Generated keys not requested. You need to specify Statement.RETURN_GENERATED_KEYS to Statement.executeUpdate() or Connection.prepareStatement().

So I did as it said.

paraseba commented 13 years ago

I have a similar problem in PostgreSQL. Not throwing an exception, but I always get {:last-index nil}

l0st3d commented 13 years ago

does this patch fix the problem?

paraseba commented 13 years ago

Unfortunately no. The problem is more complex in PostgreSQL since getGeneratedKeys is not supported for batch execution (http://postgresql.1045698.n5.nabble.com/PreparedStatement-batch-statement-impossible-td3406927.html). Any ideas on how to solve this problem?

UPDATE: with the patch applied an exception is thrown by PostgreSQL. So probably this patch isn't a good idea

l0st3d commented 13 years ago

I'm afraid not - my PostgreSQL experience is pretty limited. I'd just be googling. Sorry.

l0st3d commented 13 years ago

UPDATE: with the patch applied an exception is thrown by PostgreSQL. So probably this patch isn't a good idea

In that case, I'd suggest that the whole id as meta-data thing needs a little re-think.

paraseba commented 13 years ago

That, or we need to move away from executeBatch. Apparently Oracle doesn't support getGeneratedKeys for batch either.

sigurdteigen commented 13 years ago

This problem disappeared for me after switching from [com.mysql/connectorj "5.1.12"] to [mysql/mysql-connector-java "5.1.6"]

bendlas commented 12 years ago

This should be fixed by 257a5e02c998923a1457 Please let me know if it works for you.

l0st3d commented 12 years ago

this appears fixed. Many thanks