metabase / toucan

A classy high-level Clojure library for defining application models and retrieving them from a DB
Eclipse Public License 1.0
570 stars 49 forks source link

Select queries do not work with custom types #88

Closed marksto closed 2 years ago

marksto commented 2 years ago

Hi @camsaul! A regression issue was introduced with the latest library version upgrade, I guess. (Or probably I didn't notice this one before.) Select queries simply do not work with custom types, e.g. native PostgreSQL ENUM type. There is an exception that happens during the where+ clause construction.

class java.lang.ClassCastException - class clojure.lang.PersistentVector cannot be cast to class clojure.lang.Named (clojure.lang.PersistentVector and clojure.lang.Named are in unnamed module of loader 'app')
           toucan.test_models.pg_enum$kwd__GT_pg_enum$invokeStatic (pg_enum.clj:17)
           on (pg_enum.clj:15)
           toucan.models$do_type_fn$invokeStatic (models.clj:358)
           on (models.clj:354)
           toucan.db$where_PLUS_$invokeStatic (db.clj:463)
           on (db.clj:453)
           toucan.db$select_one$invokeStatic (db.clj:628)
...

So the fact is the current where+ fn implementation doesn't cater for the things like [:= <custom_type_value>].

Will provide you with a fix soon. Had to develop one during the weekend.

Cheers!

camsaul commented 2 years ago

Fixed by #89