Browse Source

feat: support LTAR sort

pull/7054/head
Pranav C 1 year ago
parent
commit
8f05c30ddb
  1. 34
      packages/nocodb/src/db/sortV2.ts

34
packages/nocodb/src/db/sortV2.ts

@ -78,6 +78,7 @@ export default async function sortV2(
}
break;
case UITypes.Lookup:
case UITypes.LinkToAnotherRecord:
{
const rootAlias = alias;
{
@ -92,39 +93,6 @@ export default async function sortV2(
}
}
break;
case UITypes.LinkToAnotherRecord:
{
const relation =
await column.getColOptions<LinkToAnotherRecordColumn>();
if (relation.type !== 'bt') return;
const colOptions =
(await column.getColOptions()) as LinkToAnotherRecordColumn;
const childColumn = await colOptions.getChildColumn();
const parentColumn = await colOptions.getParentColumn();
const childModel = await childColumn.getModel();
await childModel.getColumns();
const parentModel = await parentColumn.getModel();
await parentModel.getColumns();
const selectQb = knex(
baseModelSqlv2.getTnPath(parentModel.table_name),
)
.select(parentModel?.displayValue?.column_name)
.where(
`${baseModelSqlv2.getTnPath(parentModel.table_name)}.${
parentColumn.column_name
}`,
knex.raw(`??`, [
`${baseModelSqlv2.getTnPath(childModel.table_name)}.${
childColumn.column_name
}`,
]),
);
qb.orderBy(selectQb, sort.direction || 'asc', nulls);
}
break;
case UITypes.SingleSelect: {
const clientType = knex.clientType();
if (clientType === 'mysql' || clientType === 'mysql2') {

Loading…
Cancel
Save