Closed flyingmachine closed 2 years ago
Interesting. I'll add a note to the documentation about this -- that extension would have to be in user-space, where an SQLite dependency of whatever version has been added.
The reason for this weirdness is that SQLite has a strange combination ResultSet/Metadata object and next.jdbc
already has a case for that:
ResultSet
(datafy [this]
;; SQLite has a combination ResultSet/Metadata object...
(if (instance? ResultSetMetaData this)
(datafy-result-set-meta-data this)
(let [s (.getStatement this)
c (when s (.getConnection s))]
(cond-> (safe-bean this {})
c (assoc :rows (rs/datafiable-result-set this c {}))))))
Without that special case, quite a few tests fail -- basically anywhere that tries to datafy metadata instead of result sets. I'm going to have to do some testing that adding this extension doesn't break other things with SQLite.
Yup, adding this extension breaks tests which means it breaks some of how things are supposed to work. I'll have to dig into this some more to establish how to make this case work without breaking other things.
Seems like a tricky one!
I've been noodling on how to make this work and I honestly can't think of something that makes sense. If I'm understanding this correctly, SQLite's implementation makes it impossible to distinguish cases where you want ResultSet
behavior for datafy
from those where you want ResultSetMetaData
?
For my use case, it looks like using next.jdbc.result-set/datafiable-result-set
directly works well enough.
@flyingmachine Yup, unfortunately, SQLite's implementation just makes some things ambiguous as far as selecting the intended behavior there.
@flyingmachine See https://github.com/xerial/sqlite-jdbc/blob/master/src/main/java/org/sqlite/jdbc4/JDBC4ResultSet.java#L30 (and note the 47 SQLFeatureNotSupportedException
cases!).
Describe the bug
Calling
(clojure.datafy/datafy (-> conn .getMetaData (.getTables nil nil nil nil)))
returns column information for the results rather than the results themselvesTo Reproduce
Run the following:
This returns:
Expected behavior
The above should return:
Stacktraces
NA
project.clj/deps.edn
Environment (please complete the following information):
Additional context
The following fixes this problem: