sql

All things SQL and JDBC...
Gleb Posobin 2020-12-15T14:13:16.487500Z

Say I do a query like SELECT * FROM nodes n1 JOIN nodes n2 ON n1.parent_id = n2.id, next.jdbc assigns keys :nodes/* to all the fields, so I can't get all the fields from the result. What should I do? Is there a way to make jdbc assign keys in the :n1/ and :n2/ format?

seancorfield 2020-12-15T18:38:04.488300Z

@posobin Per the Getting Started docs: > If your SQL query joins a table to itself under different aliases, the qualified column names will conflict because they are based on the underlying table name provided by the JDBC driver rather the alias you used in your query -- again, use aliases in SQL to make those column names distinct. So you need to explicitly alias the columns you need to different names in this case.

Gleb Posobin 2020-12-15T18:41:10.488600Z

I see, thank you!

seancorfield 2020-12-15T18:50:42.490300Z

clojure.java.jdbc automatically renames conflicts for you -- but you have no control over which column is renamed and which is the original (not good). next.jdbc makes you do it explicitly. The underlying issue is that SQL/JDBC don't do anything to help you here since they happily allow duplicate columns in results.