Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: RelationshipJoiner raw & sub-query orders #15261

Open
wants to merge 5 commits into
base: 3.x
Choose a base branch
from

Conversation

ralphjsmit
Copy link
Contributor

This PR fixes two situations in the RelationshipJoiner that did not work:

  • ->orderByRaw("CASE WHEN role = 'PIC' THEN 1 ELSE 2 END")
  • ->orderBy(fn (Builder $query) => $query->selectRaw("CASE WHEN role = 'PIC' THEN 1 ELSE 2 END"))

This PR fixes both cases to make the RelationshipJoiner handle them correctly. There might always be edge cases regarding this part of the RelationshipJoiner, like when the raw order by contains a binding, but at least this makes the joiner handle a few more common cases.

@danharrin danharrin added the bug Something isn't working label Jan 6, 2025
@danharrin
Copy link
Member

The code looks great, but would you mind writing some tests for this? It's getting to a point where the conditions are quite complex and I would hate for them to break in the future.

@danharrin danharrin modified the milestones: v2, v3 Jan 6, 2025
@ralphjsmit
Copy link
Contributor Author

Yes, sure! Will do later this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants