Skip to content

Conversation

@juliensagot
Copy link
Contributor

We can already call jsonGroupArray() on columns sourced from a regular join, because the column is guaranteed to exist:

Reminder
  .join(RemindersList.all) { $0.remindersListID.eq($1.id) }
  .group(by: \.remindersListID)
  .select { reminder, list in
    (list.title, reminder.title.jsonGroupArray())
  }

Left joins were different: the only helper that understood optional tables worked at the table level, so if you wanted just one column you had to build the CASE … FILTER … scaffolding yourself.
This PR adds the missing column-level overload for optional tables, so the same syntax now works when the join may return NULL rows:

RemindersList
  .group(by: \.id)
  .leftJoin(Reminder.all) { $0.id.eq($1.remindersListID) }
  .select { list, reminder in
    (list.title, reminder.title.jsonGroupArray())
  }

Tests cover the new overload alongside the existing distinct/order/filter behavior.

@stephencelis
Copy link
Member

@juliensagot Did you mean to close this without follow-up?

@juliensagot
Copy link
Contributor Author

@stephencelis Yes! That syntax is already supported by the current version of the library, so that PR is useless 😅

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants