1
0
Fork 0
mirror of synced 2024-08-14 17:42:01 +12:00

Merge branch 'develop' into BUDI-7189/type_search

This commit is contained in:
Adria Navarro 2023-08-04 16:23:07 +01:00 committed by GitHub
commit 259bb3cdc2
4 changed files with 23 additions and 3 deletions

View file

@ -1,5 +1,5 @@
{
"version": "2.8.29-alpha.17",
"version": "2.8.29-alpha.18",
"npmClient": "yarn",
"packages": [
"packages/*"

View file

@ -27,7 +27,6 @@
"array",
"attachment",
"boolean",
"formula",
"json",
]

View file

@ -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"

View file

@ -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]`,
})
})
})