camsaul / toucan2

Successor library to Toucan with a modern and more-extensible API, more consistent behavior, and support for different backends including non-JDBC databases and non-HoneySQL queries. Currently in active beta.
Eclipse Public License 1.0
77 stars 11 forks source link

Support returning different map types besides `Instance` #133

Open camsaul opened 1 year ago

camsaul commented 1 year ago

This was in Toucan 2 at one point, but I ultimately removed it in one of the many simplification passes

"Magic map" support is one use case, or even returning Toucan 1 record types if you're a kook. Maybe you just want plain maps? Who knows.

escherize commented 11 months ago

Put me down for plain maps.

I use into {} pretty often, e.g.:

(keys (t2/hydrate (t2/select Database :id 1337) :tables))

Which fails with

Error printing return value (ClassCastException) at clojure.lang.APersistentMap$KeySeq/first (APersistentMap.java:168).
class toucan2.instance.Instance cannot be cast to class java.util.Map$Entry (toucan2.instance.Instance is in unnamed module of loader clojure.lang.DynamicClassLoader @7731595c; java.util.Map$Entry is in module java.base of loader 'bootstrap')
markbastian commented 10 months ago

I'm also a big fan of "just gimme a map." Maybe supporting datafy would do it?