Fork me on GitHub
#sql
<
2018-03-12
>
seancorfield17:03:29

That's just what the JDBC driver returns @souenzzo -- It's why clojure.java.jdbc's test suite has to have all sorts of DB-specific logic to extract keys / know which DBs return keys etc.

seancorfield17:03:57

SQL is relatively portable but a lot of JDBC behavior isn't, unfortunately.

souenzzo17:03:18

So this "issue/limitation/behavior" is about com.h2database/h2, not about org.clojure/java.jdbc?

seancorfield17:03:36

@souenzzo clojure.java.jdbc just returns whatever the driver gives it.

seancorfield17:03:55

JDBC drivers vary a lot between databases. Of the databases I test against with clojure.java.jdbc, PostgreSQL is the only one that returns the entire row. Most of them return a result set containing just the generated key (although each database uses a different name -- for example, MySQL uses generated_key, SQLite uses last_insert_rowid()

seancorfield17:03:31

Writing portable DB-access code is a real challenge.

tanzoniteblack17:03:42

@souenzzo are you using h2 because you need something local to test postgres with? Or are you actually using both databases in your non-test codebase?

tanzoniteblack17:03:10

if it's just for testing purposes, we've used https://github.com/opentable/otj-pg-embedded with great success for downloading/creating/starting a local postgres specifically for your test run. We used to use h2 for testing, but the differences between h2 and postgres were too large and made it so we were testing things that had little resemblance to production

souenzzo18:03:00

I will look on this otj. It's just a develop tool; Real tests on CI will use postgres. (`A little lazy to run local postgres`)

seancorfield19:03:23

@souenzzo If you use Docker, running PostgreSQL locally is trivial. It's how I test clojure.java.jdbc against PostgreSQL.

tanzoniteblack20:03:33

@seancorfield we actually recently switched to a dockerified version of the pg-embedded that's still efficient in spinning new clean DB's. I have Friday afternoons to work solely on open source projects at Yummly, and that is the next project I plan on open sourcing, since it has less...tangential problems then the pg-embedded one