Skip to content

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

Closed
@shawnpwalsh

Description

@shawnpwalsh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    type: bugDEPRECATED: replace with the "bug" issue type

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions