Skip to content

PG LIKE search within isArray columns #368

Description

@TrilipuT

Hey there!

I have one issue that i have solved but seems like I didn't get to the cause of it.
So when I'm using isArray for field and substringSearch: true it sets additional " into value
See 063 in the query.

🪲📜 PG Q: SELECT "id", "plate", "name", "phones", "status", "type", "building", "flat", "created_at", "updated_at", "expire_at", "comments", "is_us_plate" FROM "vehicle" WHERE "phones" ILIKE $1 AND "status" IS DISTINCT FROM $2 AND "building" = $3 ORDER BY "id" DESC LIMIT $4 OFFSET $5 params: [ '%"063"%', 2, 'b4', 50, 0 ]

🪲📜 PG Q: SELECT COUNT(*) FROM "vehicle" WHERE "phones" ILIKE $1 AND "status" IS DISTINCT FROM $2 AND "building" = $3 values: [ '%"\\"063\\""%', 2, 'b4' ]

so seems like those quotes are ambigious for like query.
I found only one way is to replace it. In file postgres data connector. But i think that might have a better way to solve it.

if (filter.operator == AdminForthFilterOperators.LIKE || filter.operator == AdminForthFilterOperators.ILIKE) {
    let value = filter.value.replaceAll('"','');
    value = value.replaceAll('\\','');
    return [`%${value}%`];
}

Here's my column setup

{
    name: 'phones',
    type: AdminForthDataTypes.JSON,
    isArray: {
        enabled: true,
        itemType: AdminForthDataTypes.STRING,
    },
    minLength: 12,
    filterOptions: {
        debounceTimeMs: 800,
        substringSearch: true,
    },
}

Please let me know if that can be fixed somehow...
Thanks!

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions