Browse Source

fix: order by CreatedTime or auto-incremented primary key by default

pull/7586/head
Pranav C 8 months ago
parent
commit
a43c4d52d5
  1. 7
      packages/nocodb/src/db/BaseModelSqlv2.ts

7
packages/nocodb/src/db/BaseModelSqlv2.ts

@ -419,8 +419,11 @@ class BaseModelSqlv2 {
// if autogenerated string sort by created_at column if present
if (this.model.primaryKey && this.model.primaryKey.ai) {
qb.orderBy(this.model.primaryKey.column_name);
} else if (this.model.columns.find((c) => c.column_name === 'created_at')) {
qb.orderBy('created_at');
} else {
const createdCol = this.model.columns.find(
(c) => c.uidt === UITypes.CreatedTime && c.system,
);
if (createdCol) qb.orderBy(createdCol.column_name);
}
if (!ignorePagination) applyPaginate(qb, rest);

Loading…
Cancel
Save