funcool / clojure.jdbc

JDBC library for Clojure
http://funcool.github.io/clojure.jdbc/latest/
Apache License 2.0
105 stars 26 forks source link

fix reading from a boolean column #18

Closed vbedegi closed 9 years ago

vbedegi commented 9 years ago

Using clojure.jdbc with MSSQL database, reading values from boolean columns seems to always return 'false'. The ResultSet contains the correct value ('true'), but applying true? to it always return false, since true? uses identical comparison.

niwinz commented 9 years ago

Very strange, because:

(true? true)
;; => true

Just I have tested it in my repl. And the docstring is clear:

user=> (doc true?)
-------------------------
clojure.core/true?
([x])
  Returns true if x is the value true, false otherwise.

Maybe is something related to mssql? This change fixes your problem?

niwinz commented 9 years ago

I'm missing something or, mssql does not have boolean type: https://msdn.microsoft.com/en-us/library/ms378878(v=sql.110).aspx ??

vbedegi commented 9 years ago

Yes

(true? (java.lang.Boolean/TRUE)) => true

but

(true? (java.lang.Boolean. "true")) => false

I guess, their JDBC driver returns the latter. And yes, this change fixed my problem.