Replies: 1 comment
-
I solved this by changing the query and installing the unaccent extension: // migration import BaseSchema from '@ioc:Adonis/Lucid/Schema'
export default class extends BaseSchema {
protected tableName = 'clients'
public async up() {
this.defer(async (db) => {
await db.rawQuery('CREATE EXTENSION unaccent;')
})
}
public async down() {
this.defer(async (db) => {
await db.rawQuery('DROP EXTENSION IF EXISTS unaccent')
})
}
} // controller const paginatedOrders = await Order.query()
.select('*')
.orderBy('created_at', 'desc')
.preload('products')
.preload('address', (addressQuery) => {
addressQuery.preload('client', (clientQuery) => {
if (clientSearchTerm) {
clientQuery.andWhereRaw(`unaccent(name) ILIKE unaccent(?)`, [`%${clientSearchTerm}%`])
}
})
}) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Right now I've stumbled upon a bug in my code, and it relates to text having accent in the database, and when the user search for a text without them, they don't match:
For instance:
Beta Was this translation helpful? Give feedback.
All reactions