1
0
Fork 0
mirror of synced 2024-08-05 13:21:26 +12:00

Ensure that sort order is always lowercased.

This commit is contained in:
Sam Rose 2024-06-14 11:00:34 +01:00
parent 59e9658a6a
commit f3c82cbf38
No known key found for this signature in database
7 changed files with 19 additions and 36 deletions

View file

@ -14,14 +14,10 @@ import {
EmptyFilterOption, EmptyFilterOption,
SearchFilters, SearchFilters,
Table, Table,
SortOrder,
} from "@budibase/types" } from "@budibase/types"
import { db as dbCore } from "@budibase/backend-core" import { db as dbCore } from "@budibase/backend-core"
enum SortOrder {
ASCENDING = "ascending",
DESCENDING = "descending",
}
const SortOrderPretty = { const SortOrderPretty = {
[SortOrder.ASCENDING]: "Ascending", [SortOrder.ASCENDING]: "Ascending",
[SortOrder.DESCENDING]: "Descending", [SortOrder.DESCENDING]: "Descending",

View file

@ -70,11 +70,6 @@ export enum DatasourceAuthTypes {
GOOGLE = "google", GOOGLE = "google",
} }
export enum SortDirection {
ASCENDING = "ASCENDING",
DESCENDING = "DESCENDING",
}
export const USERS_TABLE_SCHEMA: Table = { export const USERS_TABLE_SCHEMA: Table = {
_id: "ta_users", _id: "ta_users",
type: "table", type: "table",

View file

@ -29,7 +29,7 @@
"filters": {}, "filters": {},
"sort": { "sort": {
"firstname": { "firstname": {
"direction": "ASCENDING" "direction": "ascending"
} }
}, },
"paginate": { "paginate": {
@ -65,9 +65,7 @@
"table": { "table": {
"type": "table", "type": "table",
"_id": "datasource_plus_8066e56456784eb2a00129d31be5c3e7__persons", "_id": "datasource_plus_8066e56456784eb2a00129d31be5c3e7__persons",
"primary": [ "primary": ["personid"],
"personid"
],
"name": "persons", "name": "persons",
"schema": { "schema": {
"year": { "year": {
@ -122,12 +120,7 @@
"name": "type", "name": "type",
"constraints": { "constraints": {
"presence": false, "presence": false,
"inclusion": [ "inclusion": ["support", "designer", "programmer", "qa"]
"support",
"designer",
"programmer",
"qa"
]
} }
}, },
"city": { "city": {
@ -180,4 +173,4 @@
"persons": "a", "persons": "a",
"tasks": "b" "tasks": "b"
} }
} }

View file

@ -30,7 +30,7 @@
}, },
"sort": { "sort": {
"productname": { "productname": {
"direction": "ASCENDING" "direction": "ascending"
} }
}, },
"paginate": { "paginate": {
@ -60,9 +60,7 @@
"table": { "table": {
"type": "table", "type": "table",
"_id": "datasource_plus_44a967caf37a435f84fe01cd6dfe8f81__products", "_id": "datasource_plus_44a967caf37a435f84fe01cd6dfe8f81__products",
"primary": [ "primary": ["productid"],
"productid"
],
"name": "products", "name": "products",
"schema": { "schema": {
"productname": { "productname": {
@ -106,4 +104,4 @@
"tasks": "b", "tasks": "b",
"products_tasks": "c" "products_tasks": "c"
} }
} }

View file

@ -23,7 +23,7 @@
}, },
"sort": { "sort": {
"productname": { "productname": {
"direction": "ASCENDING" "direction": "ascending"
} }
}, },
"paginate": { "paginate": {
@ -50,9 +50,7 @@
"table": { "table": {
"type": "table", "type": "table",
"_id": "datasource_plus_8066e56456784eb2a00129d31be5c3e7__products", "_id": "datasource_plus_8066e56456784eb2a00129d31be5c3e7__products",
"primary": [ "primary": ["productid"],
"productid"
],
"name": "products", "name": "products",
"schema": { "schema": {
"productname": { "productname": {
@ -91,4 +89,4 @@
"primaryDisplay": "productname" "primaryDisplay": "productname"
} }
} }
} }

View file

@ -56,7 +56,7 @@
}, },
"sort": { "sort": {
"taskname": { "taskname": {
"direction": "ASCENDING" "direction": "ascending"
} }
}, },
"paginate": { "paginate": {
@ -106,9 +106,7 @@
"table": { "table": {
"type": "table", "type": "table",
"_id": "datasource_plus_44a967caf37a435f84fe01cd6dfe8f81__tasks", "_id": "datasource_plus_44a967caf37a435f84fe01cd6dfe8f81__tasks",
"primary": [ "primary": ["taskid"],
"taskid"
],
"name": "tasks", "name": "tasks",
"schema": { "schema": {
"executorid": { "executorid": {
@ -199,4 +197,4 @@
"persons": "c", "persons": "c",
"products_tasks": "d" "products_tasks": "d"
} }
} }

View file

@ -4,6 +4,7 @@ import {
RowSearchParams, RowSearchParams,
SearchFilters, SearchFilters,
SearchResponse, SearchResponse,
SortOrder,
} from "@budibase/types" } from "@budibase/types"
import { isExternalTableID } from "../../../integrations/utils" import { isExternalTableID } from "../../../integrations/utils"
import * as internal from "./search/internal" import * as internal from "./search/internal"
@ -78,6 +79,10 @@ export async function search(
} }
} }
if (options.sortOrder) {
options.sortOrder = options.sortOrder.toLowerCase() as SortOrder
}
const table = await sdk.tables.getTable(options.tableId) const table = await sdk.tables.getTable(options.tableId)
options = searchInputMapping(table, options) options = searchInputMapping(table, options)