Merge pull request #8123 from Budibase/bug/sev3/public-api-equals-number
Public api equals number text type fix
This commit is contained in:
commit
0d7e0531fc
|
@ -145,7 +145,7 @@ class QueryBuilder {
|
|||
* @param options The preprocess options
|
||||
* @returns {string|*}
|
||||
*/
|
||||
preprocess(value, { escape, lowercase, wrap } = {}) {
|
||||
preprocess(value, { escape, lowercase, wrap, type } = {}) {
|
||||
const hasVersion = !!this.version
|
||||
// Determine if type needs wrapped
|
||||
const originalType = typeof value
|
||||
|
@ -159,7 +159,7 @@ class QueryBuilder {
|
|||
}
|
||||
|
||||
// Wrap in quotes
|
||||
if (originalType === "string" && !isNaN(value) && !escape) {
|
||||
if (originalType === "string" && !isNaN(value) && !type) {
|
||||
value = `"${value}"`
|
||||
} else if (hasVersion && wrap) {
|
||||
value = originalType === "number" ? value : `"${value}"`
|
||||
|
@ -256,6 +256,7 @@ class QueryBuilder {
|
|||
value = builder.preprocess(value, {
|
||||
escape: true,
|
||||
lowercase: true,
|
||||
type: "string",
|
||||
})
|
||||
return `${key}:${value}*`
|
||||
})
|
||||
|
@ -284,6 +285,7 @@ class QueryBuilder {
|
|||
value = builder.preprocess(value, {
|
||||
escape: true,
|
||||
lowercase: true,
|
||||
type: "fuzzy",
|
||||
})
|
||||
return `${key}:${value}~`
|
||||
})
|
||||
|
|
|
@ -173,4 +173,24 @@ describe("internal search", () => {
|
|||
}, PARAMS)
|
||||
checkLucene(response, `*:* AND NOT column:(a AND b AND c)`, PARAMS)
|
||||
})
|
||||
|
||||
it("test equal without version query", async () => {
|
||||
PARAMS.version = null
|
||||
const response = await search.paginatedSearch({
|
||||
equal: {
|
||||
"column": "1",
|
||||
}
|
||||
}, PARAMS)
|
||||
|
||||
const query = response.rows[0].query
|
||||
const json = JSON.parse(query)
|
||||
if (PARAMS.sort) {
|
||||
expect(json.sort).toBe(`${PARAMS.sort}<${PARAMS.sortType}>`)
|
||||
}
|
||||
if (PARAMS.bookmark) {
|
||||
expect(json.bookmark).toBe(PARAMS.bookmark)
|
||||
}
|
||||
expect(json.include_docs).toBe(true)
|
||||
expect(json.q).toBe(`(*:* AND column:"1") AND tableId:${PARAMS.tableId}`)
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue