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 parameter escape in SQLiteDriver #9400

Merged

Conversation

michaelwolz
Copy link
Contributor

Description of change

(Re-)Fixes: #1981

The issue in #1981 re-occurred after 0.3.0 because nativeParameters became deprecated and new find methods use parmeters instead which where not fixed in #7122. This PR adds the boolean parameter escape for all kind of parameters and also makes additional transformations as implemented in the BetterSqlite3QueryRunner obsolete.

The problem seems to be mainly related to the CordovaDriver where I also encountered this problem after migration to > 0.3.0. However, I think it's appropriate to have this fixed in the AbstractSqliteDriver because it is obviously affecting BetterSqlite3 too and a correct way of handling boolean properties in SQLite anyways :).

A similar approach was already submitted via: #9009 which was closed unfortunately but I added test-cases in addition and instead of just converting the boolean values to strings this PR will pass them as numeric query parameters.

Pull-Request Checklist

  • Code is up-to-date with the master branch
  • npm run format to apply prettier formatting
  • npm run test passes with this change
  • This pull request links relevant issues as Fixes #0000
  • There are new or updated unit tests validating the change
  • Documentation has been updated to reflect this change N/A
  • The new commits follow conventions explained in CONTRIBUTING.md

michaelwolz and others added 4 commits September 22, 2022 14:07
sqlite does not support boolean parameters. Even though sqlite is able to transform true to 1 and false to 0 there might be some limitations with other implemenations that build up on this.

Fixes: typeorm#1981 (again)
3cbbe90 already handles the boolean value transformation so it is not necessary to have additional code in the query runner for handling this
@AlexMesser AlexMesser merged commit 4a36d0e into typeorm:master Nov 5, 2022
@michaelwolz michaelwolz deleted the fix/sqlite-driver-parameter-escape branch November 7, 2022 08:28
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.

[Bug] Boolean values not casted properly when used in .find() condition
2 participants