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

2 participants
@shawnpwalsh

shawnpwalsh commented Sep 1, 2015

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 mickhansen added the bug label Sep 2, 2015

@mickhansen

This comment has been minimized.

Contributor

mickhansen commented Sep 2, 2015

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