sql

All things SQL and JDBC...
seancorfield 2020-10-13T19:27:44.085600Z

Does anyone using JOIN USING (cols) ? I didn't even realize it was a thing until yesterday 😐

3✋1❌
2020-10-14T12:48:09.100800Z

Same here. I learn this, like 6 months ago.

iarenaza 2020-10-15T15:11:25.101400Z

We sometimes do, although sparingly.

dharrigan 2020-10-13T20:23:23.086400Z

Sometimes, although not in my Clojure code atm

isak 2020-10-13T20:24:54.087900Z

I can't, I think you'd need a DB that used full length primary key names for that to be useful. E.g., your "projects" table having a primary key of "project_id" instead of "id"

dharrigan 2020-10-13T20:33:22.088400Z

It doesn't have to be a primary key - can be any column where the names (and type!) are the same

isak 2020-10-13T20:35:01.089200Z

Yea, I understand, but I figured primary keys and foreign keys be the main use case

dharrigan 2020-10-13T20:36:24.089900Z

Agreed 🙂

dominicm 2020-10-13T20:38:37.091100Z

We have a lot of joins which could use that, although we don't right now. We have multiple keys from different places, so joining them up like that is natural.

seancorfield 2020-10-13T20:57:16.091900Z

Apparently HoneySQL 1.0 supports this (I just found some tests for it) so now I have to make HoneySQL 2.0 support it 😐

seancorfield 2020-10-13T20:58:16.093Z

I don't think we have a single JOIN anywhere in our codebase where the column names are identical... it's nearly always on sometable.id = thistable.sometable_id

2020-10-13T21:08:48.094900Z

I do sometimes wish we used sometable_id as the column name even in sometable, having columns named 'id' can result in some ambiguous keys in maps (didn't know about USING either)

seancorfield 2020-10-13T21:27:54.095600Z

Yeah, there's definitely some pros to consistently using <table>_id even for the PK of <table>...