Skip to content

Conversation

@hf-kklein
Copy link
Contributor

@hf-kklein hf-kklein commented Oct 21, 2025

maybe we need to add COLLATE NOCASE to the where clause, idk...

see: Hochfrequenz/xml-fundamend-python#193

@hf-krechan : man müsste mal aus dem fundamend-pr eine DB bauen und schauen ob das so funktioniert. ich glaube aber, dass aktuell der index auf der spalte nicht genutzt wird und ohne collate nocase nur für ascii-zeichen genutzt würde (siehe auch die description vom fundanemnd-pr)

… index)

maybe we need to add `COLLATE NOCASE` to the where clause, idk...

see: Hochfrequenz/xml-fundamend-python#193
Copilot AI review requested due to automatic review settings October 21, 2025 08:41
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR optimizes database query performance by removing LOWER(...) function calls from SQL LIKE search operations, allowing the database to utilize indexes more effectively. The search values are still converted to lowercase on the application side before being passed to the query.

Key changes:

  • Removed LOWER() SQL function wrapping from column references in LIKE clauses
  • Maintained .toLowerCase() on search parameter values to preserve case-insensitive matching

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copilot AI review requested due to automatic review settings October 21, 2025 08:44
@hf-kklein hf-kklein changed the title perf(search): simplify LIKE search (drop LOWER(...) and hence use index) perf(search): simplify LIKE search (drop LOWER(...) in favour of COLLATE NOCASE) Oct 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment on lines +159 to 160
queryBuilder.andWhere(`al.${columnName} COLLATE NOCASE LIKE :${paramBase}_contains`, {
[`${paramBase}_contains`]: `%${value.contains.toLowerCase()}%`,
Copy link

Copilot AI Oct 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The columnName variable is interpolated directly into the SQL string without sanitization, creating a potential SQL injection vulnerability. Consider using a whitelist of allowed column names or TypeORM's column metadata to validate the column name before interpolation.

Copilot uses AI. Check for mistakes.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

was like this before. out of scope for this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants