Here's some warts, when working with boolean fields from sql
databases.

(if (with-db (sql-val ["select convert(bit, 0)"])) "Yes", "no")

will return "Yes". This is because contrib.sql returns java Booleans,
not clojure tru/false.

(if (= false (with-db (sql-val ["select null"]))) "Yes", "no")

will return "no". This is because null is not false in clojure.

So the only way to correctly deal with booleans from sql databases is
to explicitly test for true:

(if (= true (with-db (sql-val ["select null"]))) "Yes", "no")

or
(if (not (= true (with-db (sql-val ["select null"])))) "Yes", "no")

That's awkward, especially for those of us, coming from Common Lisp.


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to