[#4500] added the field name as part of the `@request.data.*` relations join
This commit is contained in:
parent
eff09852a4
commit
3551dea44a
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
- Fixed `OnAfterApiError` debug log `nil` error reference ([#4498](https://github.com/pocketbase/pocketbase/issues/4498)).
|
- Fixed `OnAfterApiError` debug log `nil` error reference ([#4498](https://github.com/pocketbase/pocketbase/issues/4498)).
|
||||||
|
|
||||||
|
- Added the field name as part of the `@request.data.someRelField.*` join to handle the case when a collection has 2 or more relation fields pointing to the same place ([#4500](https://github.com/pocketbase/pocketbase/issues/4500)).
|
||||||
|
|
||||||
- Updated Go deps and bumped the min Go version in the GitHub release action to Go 1.22.1 since it comes with [some security fixes](https://github.com/golang/go/issues?q=milestone%3AGo1.22.1).
|
- Updated Go deps and bumped the min Go version in the GitHub release action to Go 1.22.1 since it comes with [some security fixes](https://github.com/golang/go/issues?q=milestone%3AGo1.22.1).
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -305,30 +305,33 @@ func (r *runner) processRequestInfoRelationField(dataField *schema.SchemaField)
|
||||||
}
|
}
|
||||||
|
|
||||||
r.activeCollectionName = dataRelCollection.Name
|
r.activeCollectionName = dataRelCollection.Name
|
||||||
r.activeTableAlias = inflector.Columnify("__data_" + dataRelCollection.Name)
|
r.activeTableAlias = inflector.Columnify("__data_" + dataRelCollection.Name + "_" + dataField.Name)
|
||||||
|
|
||||||
// join the data rel collection to the main collection
|
// join the data rel collection to the main collection
|
||||||
r.resolver.registerJoin(
|
r.resolver.registerJoin(
|
||||||
inflector.Columnify(r.activeCollectionName),
|
r.activeCollectionName,
|
||||||
r.activeTableAlias,
|
r.activeTableAlias,
|
||||||
dbx.In(
|
dbx.In(
|
||||||
fmt.Sprintf("[[%s.id]]", inflector.Columnify(r.activeTableAlias)),
|
fmt.Sprintf("[[%s.id]]", r.activeTableAlias),
|
||||||
list.ToInterfaceSlice(dataRelIds)...,
|
list.ToInterfaceSlice(dataRelIds)...,
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
if options.MaxSelect == nil || *options.MaxSelect != 1 {
|
if options.IsMultiple() {
|
||||||
r.withMultiMatch = true
|
r.withMultiMatch = true
|
||||||
}
|
}
|
||||||
|
|
||||||
// join the data rel collection to the multi-match subquery
|
// join the data rel collection to the multi-match subquery
|
||||||
r.multiMatchActiveTableAlias = inflector.Columnify("__data_mm_" + dataRelCollection.Name)
|
r.multiMatchActiveTableAlias = inflector.Columnify("__data_mm_" + dataRelCollection.Name + "_" + dataField.Name)
|
||||||
r.multiMatch.joins = append(
|
r.multiMatch.joins = append(
|
||||||
r.multiMatch.joins,
|
r.multiMatch.joins,
|
||||||
&join{
|
&join{
|
||||||
tableName: inflector.Columnify(r.activeCollectionName),
|
tableName: r.activeCollectionName,
|
||||||
tableAlias: r.multiMatchActiveTableAlias,
|
tableAlias: r.multiMatchActiveTableAlias,
|
||||||
on: dbx.In(r.multiMatchActiveTableAlias+".id", list.ToInterfaceSlice(dataRelIds)...),
|
on: dbx.In(
|
||||||
|
fmt.Sprintf("[[%s.id]]", r.multiMatchActiveTableAlias),
|
||||||
|
list.ToInterfaceSlice(dataRelIds)...,
|
||||||
|
),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue