Skip to content

feat: [#1000] add LeftJoin, RightJoin and CrossJoin to orm.Query - #1576

Open
JGamboa wants to merge 3 commits into
goravel:masterfrom
JGamboa:feat/orm-query-joins
Open

JGamboa wants to merge 3 commits into
goravel:masterfrom
JGamboa:feat/orm-query-joins

Conversation

@JGamboa

@JGamboa JGamboa commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

📑 Description

Part of goravel/goravel#1000 (joins section). Follows #1575. Roadmap: goravel/goravel#1015

Adds LeftJoin, RightJoin and CrossJoin to orm.Query, with the same signatures as db.Query:

facades.Orm().Query().Model(&User{}).
    Select("users.*", "roles.name as role").
    LeftJoin("roles ON roles.id = users.role_id").
    Get(&users)
  • Each method prefixes its join keyword and stores the clause next to the existing Join, so joins are rendered in call order. The existing Join keeps taking the full SQL, unchanged.
  • Note on SQLite: RIGHT JOIN needs SQLite ≥ 3.39. The driver used in the tests (ncruces/go-sqlite3) embeds 3.50, so it works there.
  • Mocks are regenerated.

This branch is independent from #1575. Both add the same test import, so whichever merges second needs a trivial rebase.

✅ Checks

  • Added test cases for my code
    • Unit: TestJoinClauses covers the generated SQL, the bindings and mixed join order.
    • Integration: TestLeftJoin, TestRightJoin, TestCrossJoin and TestToSqlWithJoins, including Count with joins and ToSql/ToRawSql. They pass on Postgres, MySQL, SQLite and SQL Server.

Align orm.Query with db.Query by adding LeftJoin, RightJoin and CrossJoin
with the same signatures. The clauses are prefixed with the join keyword
and stored together with Join, so joins are rendered in call order.
Cover LeftJoin, RightJoin and CrossJoin against all drivers, including Count with joins and ToSql/ToRawSql output.
@codecov

codecov Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.23%. Comparing base (7ffe4a8) to head (029c588).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1576      +/-   ##
==========================================
+ Coverage   72.91%   73.23%   +0.32%     
==========================================
  Files         412      412              
  Lines       26893    26897       +4     
==========================================
+ Hits        19608    19697      +89     
+ Misses       7283     7198      -85     
  Partials        2        2              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@JGamboa
JGamboa marked this pull request as ready for review October 18, 2026 23:47
@JGamboa

JGamboa commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

Review Ready

@JGamboa
JGamboa requested a review from a team as a code owner October 18, 2026 23:47
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.

1 participant