LauJensen / clojureql

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

Add check if JDBC driver supports generated keys #107

Closed andeee closed 13 years ago

andeee commented 13 years ago

JDBC API has DatabaseMetaData to check for features of the database. Since JDBC3 supportsGetGeneratedKeys is available.

See http://download.oracle.com/javase/6/docs/api/java/sql/DatabaseMetaData.html#supportsGetGeneratedKeys().

Attention: sqlite-jdbc reports false, but supports it - I'll file a bug on this for sqlite-jdbc

andeee commented 13 years ago

sorry the amount of commits, just trying to get started with git

andeee commented 13 years ago

Filed bug for sqlite-jdbc: http://code.google.com/p/sqlite-jdbc/issues/detail?id=10

bendlas commented 13 years ago

Thanks for the pull request. I have to ask you to clarify and change a few things, before commiting this.

andeee commented 13 years ago

Thank you for your comments and advice.

I'll try to clarify my intent:

I'll now cleanup the commits and make another pull request. If you have further questions, please ask.

bendlas commented 13 years ago

Great! As far as I have understood, SQL Anywhere is embedded and thus can be used in the test suite w/o any external config. If so, please add it and add test cases, highlighting the wrong behavior. Please also double check, that there are test cases in place for everything that might be affected by your patch (to a reasonable extent, it will be audited anyway).

The latest problems we had in that area (of auto-generated keys), was with newer MySQL drivers. They would throw, if you didn't fetch the generated keys after a query.

Whereas the Postgres Driver would throw, when trying to get generated keys in batch mode.

I implemented a workaround, by only getting generated keys when not in batch mode, as per 257a5e02

You might want to check how your work interacts with that behavior.

Thanks for your help!

andeee commented 13 years ago

Thanks for your further info! SQL Anywhere is not as embedded as for example derby or hsqldb. Therefore one must download the Developer Editon from Sybase, create the database and deploy the jdbc driver to a local maven repo since it's not available on maven central.

Should I add it to the test cases anyway?

bendlas commented 13 years ago

In this case, please not. If you can easily reproduce it with another db, go ahead, otherwise just make sure it doesn't break anything.

Thanks!

andeee commented 13 years ago

cleaned up commits in #108