Using "in" operator with uuid types causes "invalid input syntax" error
See original GitHub issueIssue type:
- bug report
Database system/driver:
-
postgres
v11
TypeORM version:
-
latest
0.2.26
With postgres, “in” operator is valid on UUID types:
SELECT x.* FROM my_table x WHERE x."_id" IN ('77dec6ee-8d39-4b73-825a-6190628d2953','7900b8c6-c239-45e1-9ca8-2d1a244eb881')
However, the following code throws an error:
repository.find({
where: {
_id: In(['77dec6ee-8d39-4b73-825a-6190628d2953', '7900b8c6-c239-45e1-9ca8-2d1a244eb881']),
}
});
QueryFailedError invalid input syntax for type uuid: "{"_type":"in","_value":["77dec6ee-8d39-4b73-825a-6190628d2953", "7900b8c6-c239-45e1-9ca8-2d1a244eb881"],"_useParameter":true,"_multipleParameters":true}"
Issue Analytics
- State:
- Created 3 years ago
- Reactions:8
- Comments:21 (7 by maintainers)
Top Results From Across the Web
Nestjs - QueryFailedError: invalid input syntax for type uuid
I ran into a similar error and kept landing back on this issue. Eventually discovered (via github.com/nestjs/nest/issues/1667) that the ordering ...
Read more >typeorm/typeorm - Gitter
When I try to execute the query, I get invalid input syntax for type timestamp: ... findOne() from the database and then save...
Read more >BUG #17139: Invalid input syntax for uuid (politely this time!)
ones. It says: ERROR: invalid input syntax for type uuid: Aside from the lack of the literal word "value" it seems to meet...
Read more >ERROR: invalid input syntax for type uuid on wrong column
I need to write a function because I am using postgraphile to make the request to insert the data. Here is my SQL...
Read more >ORA-40001 to ORA-40999 - Oracle Help Center
ORA-40102: invalid input string for data mining operation string. Cause: The input parameter was ... Cause: The expression had syntax or semantic errors....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I believe the answer to this question is in this other issue: https://github.com/typeorm/typeorm/issues/1985
All you have to do is use the new ‘…’ operator to spread the array inside the In clause of your query, like so:
Note the
:...key
thing, but I don’t see this’s being mentioned anywhere in the changelog… Am I missing anything?_Originally posted by @lednhatkhanh in https://github.com/typeorm/typeorm/issues/1985#issuecomment-383270029_
Similar effect for inside query builder…
throwing this error:
Interestingly, the search will work if I add the parameter value inside the query, but only if I use single quotes like here: