honeysql

rafaeldelboni 2023-08-12T18:19:44.100849Z

Hi I have the following data query:

{:select [:*],
 :from [:definition],
 :full-join [:note [:= :note/definition-id :definition/definition-id]],
 :join
 [[:author :note-author] [:= :note/author-id :note-author/author-id]]}
and its producing the following sql:
SELECT *
  FROM definition
  INNER JOIN author AS note_author ON note.author_id = note_author.author_id
  FULL JOIN note ON note.definition_id = definition.definition_id
What should I do to make the inner join appear after the full join?

✅ 1
rafaeldelboni 2023-08-12T18:24:14.849349Z

Ow wow I just read about :join-by in the docs

{:select [:*],
 :from [:definition],
 :join-by
 [:full
  [:note [:= :note/definition-id :definition/definition-id]]
  :join
  [[:author :note-author] [:= :note/author-id :note-author/author-id]]]}
This solves my problem

seancorfield 2023-08-12T19:13:44.883459Z

Yup, not all databases care about join order but some do -- so :join-by was added for those "sensitive" databases 🙂

seancorfield 2023-08-12T19:14:02.523739Z

(I mean, SQL is relational so order absolutely should not matter)

rafaeldelboni 2023-08-12T19:33:36.744999Z

Yeah looks like postres is a bit more sensitive 😆

seancorfield 2023-08-12T19:46:12.535739Z

https://github.com/seancorfield/honeysql/issues/277 was the issue.

rafaeldelboni 2023-08-12T20:04:03.056129Z

Thanks a lot for all your work on this, this is a incredible library together next-jdbc it's super powerfull