fukamachi / mito

An ORM for Common Lisp with migrations, relationships and PostgreSQL support
292 stars 31 forks source link

find-dao cannot find NULL values in row (includes patch) #125

Open prxq2 opened 1 year ago

prxq2 commented 1 year ago

Hi,

something like this

(mito:find-dao 'thing :text text :whatever :null)

produces SQL like

;; SELECT * FROMthingWHERE ((text= ?) AND (whatever= NULL)) LIMIT 1 ("Etc")

which does not find the element where text="Etc" and the field "whatever" is NULL. The SQL that does this is

;; SELECT * FROMthingWHERE ((text= ?) AND (whateverIS NULL)) LIMIT 1 ("Etc")

("IS NULL" instead of "= NULL").

I've attached an admittedly sloppy workaround patch which fixes mito:find-dao for me. Sloppy in the sense that I'm not 100% sure that it will do the right thing in more complex contexts.

(Somehow github doesn't like the .patch extension today, so here is a txt with the patch.)

daonull.txt

Regards, and thanks,

Mario

PS: The variant (mito:find-dao 'thing :text text :whatever NIL) raises an error in the original, but works with this patch.