Browse Source

fix: set alias for subquery

pull/6987/head
Pranav C 1 year ago
parent
commit
37fa7c03ec
  1. 4
      packages/nocodb/src/db/generateLookupSelectQuery.ts

4
packages/nocodb/src/db/generateLookupSelectQuery.ts

@ -133,7 +133,7 @@ export default async function generateLookupSelectQuery({
let nestedLookupColOpt: LookupColumn; let nestedLookupColOpt: LookupColumn;
if (lookupColumn.uidt === UITypes.Lookup) { if (lookupColumn.uidt === UITypes.Lookup) {
nestedLookupColOpt = await lookupColumn.getColOptions<LookupColumn>(); nestedLookupColOpt = await lookupColumn.getColOptions<LookupColumn>();
relationCol = await nestedLookupColOpt.getRelationColumn(); relationCol = await nestedLookupColOpt.getRelationColumn();
} else { } else {
relationCol = lookupColumn; relationCol = lookupColumn;
@ -309,7 +309,7 @@ export default async function generateLookupSelectQuery({
return { return {
builder: knex builder: knex
.select(knex.raw('json_agg(??)::text', [lookupColumn.title])) .select(knex.raw('json_agg(??)::text', [lookupColumn.title]))
.from(selectQb), .from(selectQb.as(subQueryAlias)),
}; };
/* /*
// alternate approach with array_agg // alternate approach with array_agg

Loading…
Cancel
Save