-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Closed
Labels
Description
Issue type:
bug report
Database system/driver:
mysql / mariadb
TypeORM version:
0.2.5
example code:
import { In } from 'typeorm'
// ...
const res = await Entity.find({ where: { id: In([]) } })
// ER_PARSE_ERROR: You have an error in your SQL syntax; ...Generated SQL is similar to
SELECT * FROM users WHERE id IN();In MySql IN () (empty IN) is a syntax error. To fix it i propose that either:
- improve type annotations not to allow empty arrays to be inserted inside
Inmethod with guard for checking array.length to be > 0 (this would be closest to mysql spec) Inmethod converts empty array toFALSEso the result would be similar to
SELECT * FROM users WHERE id IN(FALSE); -- FALSE seems to work if used also in NOT IN(FALSE)- remove
IN()clause (may or may not create other sql syntax errors)
SELECT * FROM users WHERE id;bogdan, victormovchan, stormoz, JuanAmarillo, hata6502 and 9 morehata6502