Fork me on GitHub
#sql
<
2019-10-27
>
Lyn Headley23:10:30

Using honeysql and sqlite: If I do a (select :*) (from :a) where :a has column 'name', and then join two more tables each with a 'name' column, I get name_1 name_2 name_3 in the result map. Am I guranteed that name_3 is from the third table (second join table)?

seancorfield23:10:43

That's done inside clojure.java.jdbc. I'd have to check the source code to see whether you can rely on the order but I would advise not relying on that order.

seancorfield23:10:22

next.jdbc does not attempt to make columns unique like this -- but the default behavior is to make qualified column names using the table name (if available) for each column.

Lyn Headley23:10:55

Ok so I guess I need to manually name the resulting columns and include every column I want explicitly in the select clause.

seancorfield23:10:37

Just looked, the columns are processed in order, based on how they come back in the JDBC ResultSet object -- so you're guaranteed ordering if that is part of the JDBC spec I suppose (I have no idea whether it is).

seancorfield23:10:13

You could try using next.jdbc and work with qualified column names instead -- that would make it unambiguous.

seancorfield23:10:52

(I have no plans to work on clojure.java.jdbc in future, except for fixing show stopping bugs, so next.jdbc is where all active development is now)