Browse Source

fix: use option values when sorted by select columns

Re #2779

Signed-off-by: mertmit <mertmit99@gmail.com>
pull/2751/head
mertmit 2 years ago
parent
commit
eb473e012a
  1. 24
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts

24
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/sortV2.ts

@ -207,6 +207,30 @@ export default async function sortV2(
qb.orderBy(selectQb, sort.direction || 'asc');
}
break;
case UITypes.SingleSelect:
{
const clientType = knex.clientType();
if (clientType === 'mysql' || clientType === 'mysql2') {
qb.orderBy(sanitize(knex.raw('CONCAT(??)', [column.column_name])), sort.direction || 'asc');
} else if (clientType === 'mssql') {
qb.orderBy(sanitize(knex.raw('CAST(?? AS VARCHAR(MAX))', [column.column_name])), sort.direction || 'asc');
} else {
qb.orderBy(sanitize(column.column_name), sort.direction || 'asc');
}
break;
}
case UITypes.MultiSelect:
{
const clientType = knex.clientType();
if (clientType === 'mysql' || clientType === 'mysql2') {
qb.orderBy(sanitize(knex.raw('CONCAT(??)', [column.column_name])), sort.direction || 'asc');
} else if (clientType === 'mssql') {
qb.orderBy(sanitize(knex.raw('CAST(?? AS VARCHAR(MAX))', [column.column_name])), sort.direction || 'asc');
} else {
qb.orderBy(sanitize(column.column_name), sort.direction || 'asc');
}
break;
}
default:
qb.orderBy(sanitize(column.column_name), sort.direction || 'asc');
break;

Loading…
Cancel
Save