Skip to content

Commit

Permalink
Don't include unnecessary joins
Browse files Browse the repository at this point in the history
  • Loading branch information
adrinr committed Dec 12, 2024
1 parent f10ab49 commit 4fb5f8c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packages/backend-core/src/sql/sql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1239,6 +1239,12 @@ class InternalBuilder {
if (!toTable || !fromTable) {
continue
}

// Don't include if not required
if (relationship.from && !fields.find(f => f === relationship.from)) {
continue
}

const relatedTable = tables[toTable]
if (!relatedTable) {
throw new Error(`related table "${toTable}" not found in datasource`)
Expand Down

0 comments on commit 4fb5f8c

Please sign in to comment.