Browse Source

fix: remove lookup order

pull/6987/head
Pranav C 1 year ago
parent
commit
0d2ce8eab8
  1. 21
      packages/nocodb/src/db/generateLookupSelectQuery.ts

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

@ -301,15 +301,12 @@ export default async function generateLookupSelectQuery({
break; break;
} }
const subQueryAlias = getAlias();
if (baseModelSqlv2.isPg) { if (baseModelSqlv2.isPg) {
selectQb.orderBy(`${lookupColumn.title}`, 'asc');
// alternate approach with array_agg // alternate approach with array_agg
return { return {
builder: knex builder: selectQb.select(
.select(knex.raw('json_agg(??)::text', [lookupColumn.title])) knex.raw('json_agg(??)::text', [lookupColumn.title]),
.from(selectQb.as(subQueryAlias)), ),
}; };
/* /*
// alternate approach with array_agg // alternate approach with array_agg
@ -332,11 +329,9 @@ export default async function generateLookupSelectQuery({
} else if (baseModelSqlv2.isMySQL) { } else if (baseModelSqlv2.isMySQL) {
// alternate approach with JSON_ARRAYAGG // alternate approach with JSON_ARRAYAGG
return { return {
builder: knex builder: selectQb.select(
.select(
knex.raw('cast(JSON_ARRAYAGG(??) as NCHAR)', [lookupColumn.title]), knex.raw('cast(JSON_ARRAYAGG(??) as NCHAR)', [lookupColumn.title]),
) ),
.from(selectQb.as(subQueryAlias)),
}; };
// return { // return {
@ -354,14 +349,12 @@ export default async function generateLookupSelectQuery({
// ref: https://stackoverflow.com/questions/13382856/sqlite3-join-group-concat-using-distinct-with-custom-separator // ref: https://stackoverflow.com/questions/13382856/sqlite3-join-group-concat-using-distinct-with-custom-separator
// selectQb.orderBy(`${lookupColumn.title}`, 'asc'); // selectQb.orderBy(`${lookupColumn.title}`, 'asc');
return { return {
builder: knex builder: selectQb.select(
.select(
knex.raw(`group_concat(??, ?)`, [ knex.raw(`group_concat(??, ?)`, [
lookupColumn.title, lookupColumn.title,
LOOKUP_VAL_SEPARATOR, LOOKUP_VAL_SEPARATOR,
]), ]),
) ),
.from(selectQb.as(subQueryAlias)),
}; };
} }

Loading…
Cancel
Save