-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
[Bug] Boolean values not casted properly when used in .find() condition #1981
Comments
strange this must work. Can you contribute and create a PR with a failing test that reproduces this issue? |
I tried but I was not able to set up the
and tried to create a connection inside the
However when running my test I get a Do you have any suggestions on how to properly create a database connection using the |
I just tried to slightly alter the provided
to the
When calling
Same thing for |
|
hey @pleerock , it is true, that sqlite / cordova does not support So the question would be, how to use Hope this helps!? |
@johannesschobel yes, thank you, I got it from the first @robmarti post, but based on hist last post I wanted to confirm that he understands that we map boolean to number anyway since sqlite does not support boolean. |
@robmarti you need to use sqlite driver instead of cordova or provide a git repo at least. |
I added test and it works for sqlite. @daniel-lang can you please help here, is it possible that cordova work differently? |
@johannesschobel not sure if sqlite gonna work in mobiles, better to ask @daniel-lang |
I created a new repository based on the |
From my understanding, this seems to work because sqlite is able to convert
SELECT "Product"."id" AS "Product_id", "Product"."liked" AS "Product_liked"
FROM "product" "Product" WHERE "Product"."liked" = ? -- PARAMETERS: [true] So my conclusion for this issue would be, that |
What if we add here: } else if (typeof value === "boolean") {
return value === true ? 1 : 0;
} Can someone with cordova add locally this change and test changes? |
hey @daniel-lang , thank you for giving us feedback on this issue here.. However, the test-repository from @robmarti indicates a wrong behaviour of the @pleerock : good catch - we can try to apply changes locally and then give feedback on this issue.. |
@daniel-lang : So your So we need to "cast" the boolean value to its numeric representation.. We will try as @pleerock suggested and give feedback on this |
hey @pleerock and @daniel-lang , |
fixed by #2110 |
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)
* fix: sqlite boolean parameter escape 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 implementations that build up on this. Fixes: #1981 (again) * fix: remove obsolete where boolean value transformation 3cbbe90 already handles the boolean value transformation so it is not necessary to have additional code in the query runner for handling this * test: add test cases for sqlite query parameter escape * fix typo
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[x]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
TypeORM version:
[x]
latest
[ ]
@next
[x]
0.2.0
(or put your version here)Dear @pleerock and community,
before describing my actual problem, I want to thank you for this awesome project 👍
When developing a mobile application with Ionic (Cordova, respectively), I stumbled upon the following issue. Consider the following example:
I have a
Product
model, that looks as follows:and a respective
ProductRepository
in order to handle access to this model. This works so far, and i can create / update / delete models fine.However, if i want to show only the
Product
s that areliked
, I request data like this:However, when executing this query, i get an empty result. Problem is, that the database used is a
SQLite
database (remember that i use Ionic!). Connection is set up properly (remember that I can save / update / delete models respectively). TheBoolean
attribute is internally represented as aninteger
in theSQLite
database. When I use1
instead oftrue
, however, it works.How can i properly "configure" the ORM to use
boolean
values instead oftinyint
for thefind()
calls?Thank you very much for your help, really appreciate it!
Cheers
The text was updated successfully, but these errors were encountered: