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

Calling findOne with WHERE on primary key column and operator other than '=' doesn't add LIMIT 1 to query #4416

Closed
shawnpwalsh opened this issue Sep 1, 2015 · 1 comment

Comments

@shawnpwalsh
Copy link

It's possible this is intended behavior, but if so it should be detailed in the findOne documentation as you would always expect findOne to return exactly one record.

Dialect: PostgreSQL
Sequelize Version: 3.6.0
Sample Code:

yield Content.findOne({where:{id: {$gt: 7}}});

Actual output:

SELECT "id", "title" FROM "content" AS "Content" WHERE "Content"."id" > 7

Expected output:

SELECT "id", "title" FROM "content" AS "Content" WHERE "Content"."id" > 7 LIMIT 1
@mickhansen
Copy link
Contributor

A bug. We look for the presense of a primary key in where to remove the limit (easier queries), but this should only happen for primitives or buffers i guess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants