Skip to content

Commit a21de46

Browse files
authored
perf(search): simplify LIKE search (drop LOWER(...) and hence use index)
maybe we need to add `COLLATE NOCASE` to the where clause, idk... see: Hochfrequenz/xml-fundamend-python#193
1 parent 2748afb commit a21de46

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/server/repository/ahb.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,17 +156,17 @@ export default class AHBRepository {
156156
);
157157
}
158158
if (value.contains !== undefined) {
159-
queryBuilder.andWhere(`LOWER(al.${columnName}) LIKE :${paramBase}_contains`, {
159+
queryBuilder.andWhere(`al.${columnName} LIKE :${paramBase}_contains`, {
160160
[`${paramBase}_contains`]: `%${value.contains.toLowerCase()}%`,
161161
});
162162
}
163163
if (value.startsWith !== undefined) {
164-
queryBuilder.andWhere(`LOWER(al.${columnName}) LIKE :${paramBase}_starts`, {
164+
queryBuilder.andWhere(`al.${columnName} LIKE :${paramBase}_starts`, {
165165
[`${paramBase}_starts`]: `${value.startsWith.toLowerCase()}%`,
166166
});
167167
}
168168
if (value.endsWith !== undefined) {
169-
queryBuilder.andWhere(`LOWER(al.${columnName}) LIKE :${paramBase}_ends`, {
169+
queryBuilder.andWhere(`al.${columnName} LIKE :${paramBase}_ends`, {
170170
[`${paramBase}_ends`]: `%${value.endsWith.toLowerCase()}`,
171171
});
172172
}

0 commit comments

Comments
 (0)