Merge pull request #4328 from Budibase/fix/3928
Fix for SQL Server - fix pagination issue
This commit is contained in:
commit
48953c0953
|
@ -25,7 +25,7 @@
|
||||||
return base
|
return base
|
||||||
}
|
}
|
||||||
const currentTable = $tables.list.find(table => table._id === ds.tableId)
|
const currentTable = $tables.list.find(table => table._id === ds.tableId)
|
||||||
return getFields(base, { allowLinks: currentTable.sql }).map(
|
return getFields(base, { allowLinks: currentTable?.sql }).map(
|
||||||
field => field.name
|
field => field.name
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
FROM mcr.microsoft.com/mssql/server
|
FROM mcr.microsoft.com/mssql/server:2017-latest
|
||||||
|
|
||||||
ENV ACCEPT_EULA=Y
|
ENV ACCEPT_EULA=Y
|
||||||
ENV SA_PASSWORD=Passw0rd
|
ENV SA_PASSWORD=Passw0rd
|
||||||
|
|
|
@ -48,7 +48,20 @@ INSERT tasks
|
||||||
VALUES
|
VALUES
|
||||||
('Processing', 1);
|
('Processing', 1);
|
||||||
|
|
||||||
INSERT people
|
INSERT INTO people (name, age)
|
||||||
(name, age)
|
VALUES ('Bob', '30'),
|
||||||
VALUES
|
('Bert', '10'),
|
||||||
('Bob', '30');
|
('Jack', '12'),
|
||||||
|
('Mike', '31'),
|
||||||
|
('Dave', '44'),
|
||||||
|
('Jim', '43'),
|
||||||
|
('Kerry', '32'),
|
||||||
|
('Julie', '12'),
|
||||||
|
('Kim', '55'),
|
||||||
|
('Andy', '33'),
|
||||||
|
('John', '22'),
|
||||||
|
('Ruth', '66'),
|
||||||
|
('Robert', '88'),
|
||||||
|
('Bobert', '99'),
|
||||||
|
('Jan', '22'),
|
||||||
|
('Megan', '11');
|
||||||
|
|
|
@ -166,15 +166,13 @@ class InternalBuilder {
|
||||||
|
|
||||||
addSorting(query: KnexQuery, json: QueryJson): KnexQuery {
|
addSorting(query: KnexQuery, json: QueryJson): KnexQuery {
|
||||||
let { sort, paginate } = json
|
let { sort, paginate } = json
|
||||||
if (!sort) {
|
|
||||||
return query
|
|
||||||
}
|
|
||||||
const table = json.meta?.table
|
const table = json.meta?.table
|
||||||
|
if (sort) {
|
||||||
for (let [key, value] of Object.entries(sort)) {
|
for (let [key, value] of Object.entries(sort)) {
|
||||||
const direction = value === SortDirection.ASCENDING ? "asc" : "desc"
|
const direction = value === SortDirection.ASCENDING ? "asc" : "desc"
|
||||||
query = query.orderBy(`${table?.name}.${key}`, direction)
|
query = query.orderBy(`${table?.name}.${key}`, direction)
|
||||||
}
|
}
|
||||||
if (this.client === SqlClients.MS_SQL && !sort && paginate?.limit) {
|
} else if (this.client === SqlClients.MS_SQL && paginate?.limit) {
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
query = query.orderBy(`${table?.name}.${table?.primary[0]}`)
|
query = query.orderBy(`${table?.name}.${table?.primary[0]}`)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue