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: handling named parameter in string literals #31

Merged
merged 1 commit into from
Mar 10, 2024

Conversation

hirasawayuki
Copy link
Contributor

@hirasawayuki hirasawayuki commented Mar 9, 2024

fix

description

This PR introduces improvements to the handling of colons within string literals in SQL query parsing and ensures backward compatibility with existing codebases and database queries. It addresses issues where colons inside string literals were incorrectly interpreted as named parameters, leading to query parsing errors.

changes

  • Implemented logic to detect the start and end of string literals, ensuring colons within these literals are correctly identified and not treated as part of named parameters.
  • Added an escaping mechanism for colons that appear as part of string literals, allowing for explicit differentiation between literal colons and named parameter indicators.
  • Ensured that the new parsing logic retains backward (this case)compatibility by accurately processing existing queries with colons in string literals, including those with escaped colons.

@uvulpos uvulpos added the bug Something isn't working label Mar 9, 2024
Copy link
Member

@uvulpos uvulpos left a comment

Choose a reason for hiding this comment

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

maybe we have to rename variables of the function in the future since this was not a easy read to me, but for now the implementation looks good for me. Good Job 👍🏻

@uvulpos uvulpos merged commit fc7c6dc into go-sqlx:main Mar 10, 2024
1 check passed
@uvulpos
Copy link
Member

uvulpos commented Mar 10, 2024

thank you for your contribution 😎👍🏻

@hirasawayuki hirasawayuki deleted the fix/handling-named-parameter branch March 16, 2024 13:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants