Different database drivers handle different data types in different ways. You’ve extended the protocol to convert Clojure’s BigInt to a string which may work for you, but won’t necessarily work for everyone. That’s why the protocols are provided. See the documentation about them, here:
http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html#protocol-extensions-for-transforming-values <http://clojure-doc.org/articles/ecosystem/java_jdbc/using_sql.html#protocol-extensions-for-transforming-values> For most drivers, java.jdbc’s defaults "do the right thing" for most data types flowing between Clojure and SQL. Every now and then you’ll find a situation that needs an extension to the various protocols in one direction or another. As Andy noted, links to various things including JIRA are here: https://github.com/clojure/java.jdbc/#developer-information <https://github.com/clojure/java.jdbc/#developer-information> Regards, Sean > On May 7, 2015, at 6:44 PM, Alain Picard <al...@gocatch.com> wrote: > > Dear fellow clojurians, > > > The following behaviour seems (to me) rather odd. > > This succeeds: > > gocatch.job.job> (clojure.java.jdbc/query *database* ["select * from Job > where id = ?" (long 90)]) > ({:tip 200, > :vehicle-type "TAXI", > :passenger-id "43a4a489e18e09cade321fc6d5b7817f63293e58", > :creation-time #inst "2015-05-04T20:04:41.000000000-00:00", > :id 90}) > > But this fails: > gocatch.job.job> (clojure.java.jdbc/query *database* ["select * from Job > where id = ?" (bigint 90)]) > () > > Apparently, someone in the chain between clojure.java.jdbc downwards doesn't > realize that > bigints are integers. > > My _guess_ is the problem is in this protocol, in jdbc.clj (version 0.3.6) > > (extend-protocol ISQLValue > Object > (sql-value [v] v) > > nil > (sql-value [_] nil)) > > Which thinks an SQL value is the same as a lisp value. I was naïvely > expecting > to see a bunch of clauses for floats, rationals, etc in there. > > Anyway, if I try something like this: > (extend-protocol ISQLValue > clojure.lang.BigInt > (sql-value [v] (str v)) > > Object > (sql-value [v] v) > > nil > (sql-value [_] nil)) > > it fixes my problem. Anybody know if I'm on the right track? > > > Alain Picard > > > > p.s. posting here because I can't find a publically available way to post bugs > to the clojure.java.jdbc project. > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.