Don't include unnecessary joins

This commit is contained in:
Adria Navarro 2024-12-12 14:01:56 +01:00
parent 631317e6f0
commit da92c3bb05
1 changed files with 6 additions and 0 deletions

View File

@ -1239,6 +1239,12 @@ class InternalBuilder {
if (!toTable || !fromTable) { if (!toTable || !fromTable) {
continue continue
} }
// Don't include if not required
if (relationship.from && !fields.find(f => f === relationship.from)) {
continue
}
const relatedTable = tables[toTable] const relatedTable = tables[toTable]
if (!relatedTable) { if (!relatedTable) {
throw new Error(`related table "${toTable}" not found in datasource`) throw new Error(`related table "${toTable}" not found in datasource`)