Add back cte
This commit is contained in:
parent
0ef4a154ef
commit
fc22db35ac
|
@ -1604,8 +1604,17 @@ class InternalBuilder {
|
|||
|
||||
// handle relationships with a CTE for all others
|
||||
if (relationships?.length && aggregations.length === 0) {
|
||||
const mainTable = this.query.tableAliases?.[table.name] || table.name
|
||||
const cte = this.addSorting(
|
||||
this.knex
|
||||
.with("paginated", query.clone().clearSelect().select("*"))
|
||||
.select(this.generateSelectStatement())
|
||||
.from({
|
||||
[mainTable]: "paginated",
|
||||
})
|
||||
)
|
||||
// add JSON aggregations attached to the CTE
|
||||
return this.addJsonRelationships(query, table.name, relationships)
|
||||
return this.addJsonRelationships(cte, table.name, relationships)
|
||||
}
|
||||
|
||||
return query
|
||||
|
|
|
@ -161,15 +161,14 @@ export async function buildSqlFieldList(
|
|||
let table: Table
|
||||
if (isView) {
|
||||
table = await sdk.views.getTable(source.id)
|
||||
fields = fields.filter(f => table.schema[f].type !== FieldType.LINK)
|
||||
} else {
|
||||
table = source
|
||||
}
|
||||
|
||||
if (isView) {
|
||||
fields = Object.keys(helpers.views.basicFields(source)).map(
|
||||
c => `${table.name}.${c}`
|
||||
)
|
||||
fields = Object.keys(helpers.views.basicFields(source))
|
||||
.filter(f => table.schema[f].type !== FieldType.LINK)
|
||||
.map(c => `${table.name}.${c}`)
|
||||
} else {
|
||||
fields = extractRealFields(source)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue