Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix lessThan operator not applying column case #7624

Merged
merged 1 commit into from
Oct 13, 2024

Conversation

charlesBochet
Copy link
Member

@charlesBochet charlesBochet commented Oct 12, 2024

Our postgres column naming convention is camelCase ; this forces SQL queries to wrap column names with double quotes.

We previously forgot the quotes in a filter parsing case

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

PR Summary

This pull request refactors the GraphqlQueryFilterFieldParser class and fixes the 'lt' operator for proper column case handling in SQL queries.

  • Extracted computeWhereConditionParts function into a new utility file packages/twenty-server/src/engine/api/graphql/graphql-query-runner/utils/compute-where-condition-parts.ts
  • Fixed 'lt' (less than) operator in computeWhereConditionParts to ensure correct column case handling
  • Improved code organization and reusability by separating the SQL condition generation logic
  • Implemented parameterized queries in computeWhereConditionParts to prevent SQL injection
  • Added support for various operators including comparison, 'in', 'is' (NULL checks), and string matching (like, ilike, startsWith, endsWith)

2 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Comment on lines +72 to +76
case 'startsWith':
return {
sql: `"${objectNameSingular}"."${key}" LIKE :${key}${uuid}`,
params: { [`${key}${uuid}`]: `${value}` },
};
Copy link
Contributor

Choose a reason for hiding this comment

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

logic: startsWith and endsWith cases should append % to the value

@charlesBochet charlesBochet merged commit d252a23 into main Oct 13, 2024
8 checks passed
@charlesBochet charlesBochet deleted the patch-filter-less-case branch October 13, 2024 09:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant