Fix/formula as display (#11439)
* Allow formulas to be display columns in the grid * Ensure SQL Server always has a sort order
This commit is contained in:
parent
13ae01bcf4
commit
ece1c421fa
|
@ -27,7 +27,6 @@
|
|||
"array",
|
||||
"attachment",
|
||||
"boolean",
|
||||
"formula",
|
||||
"json",
|
||||
]
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ class InternalBuilder {
|
|||
addSorting(query: KnexQuery, json: QueryJson): KnexQuery {
|
||||
let { sort, paginate } = json
|
||||
const table = json.meta?.table
|
||||
if (sort) {
|
||||
if (sort && Object.keys(sort || {}).length > 0) {
|
||||
for (let [key, value] of Object.entries(sort)) {
|
||||
const direction =
|
||||
value.direction === SortDirection.ASCENDING ? "asc" : "desc"
|
||||
|
|
|
@ -26,6 +26,12 @@ function generateReadJson({
|
|||
filters: filters || {},
|
||||
sort: sort || {},
|
||||
paginate: paginate || {},
|
||||
meta: {
|
||||
table: {
|
||||
name: table || TABLE_NAME,
|
||||
primary: ["id"],
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -636,4 +642,19 @@ describe("SQL query builder", () => {
|
|||
sql: `select * from (select * from (select * from \"test\" where LOWER(\"test\".\"name\") LIKE :1) where rownum <= :2) \"test\"`,
|
||||
})
|
||||
})
|
||||
|
||||
it("should sort SQL Server tables by the primary key if no sort data is provided", () => {
|
||||
let query = new Sql(SqlClient.MS_SQL, limit)._query(
|
||||
generateReadJson({
|
||||
sort: {},
|
||||
paginate: {
|
||||
limit: 10,
|
||||
},
|
||||
})
|
||||
)
|
||||
expect(query).toEqual({
|
||||
bindings: [10],
|
||||
sql: `select * from (select top (@p0) * from [test] order by [test].[id] asc) as [test]`,
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue