Skip to content

When selecting from users table in postgres, select statement generated tries to use reserved word 'user' #3528

Closed

Description

@alexduan

Driver: postgres
Created a user model using: sequelize model:create --name User --attributes email:string

When selecting from the user model with something as simple as:

models.User.findAll({}).then(function(err, users) {
console.log(users);
});

I get the following stacktrace:
Executing (default): SELECT id, email, createdAt, updatedAt, deletedAt FROM Users AS User WHERE User.deletedAt IS NULL;
Possibly unhandled SequelizeDatabaseError: syntax error at or near "User"

Activity

  1. janmeier commented on Apr 14, 2015

    @janmeier
    Member

    Do you have quoteIdentifiers set to false? Otherwise User should automatically be quoted.

    Which seqeulize version are you using?

  2. alexduan commented on Apr 14, 2015

    @alexduan
    Author

    Yes, I have set it to false so that table names are not created with quotes
    (which is kind of weird on Postgres...).

    On Tue, Apr 14, 2015 at 1:43 AM, Jan Aagaard Meier <[email protected]

    wrote:

    Do you have quoteIdentifiers set to false? Otherwise User should
    automatically be quoted.

    Which seqeulize version are you using?

    —
    Reply to this email directly or view it on GitHub
    #3528 (comment)
    .

  3. janmeier commented on Apr 14, 2015

    @janmeier
    Member

    Well in that case there is really nothing to do - you have told sequelize that you don't want quotes, so you're not getting any :)

    quoteIdentifiers should really only be used in legacy situations where the table was created without quotes. When everything is handled by sequelize, quotes is your friend ;)

  4. mickhansen commented on Apr 14, 2015

    @mickhansen
    Contributor

    @alexduan includes don't work with quoteIdentifiers: false so i'd reenable it.

  5. alexduan commented on Apr 14, 2015

    @alexduan
    Author

    Ah, ok - that makes sense. I'm used to inspecting records via psql and was
    weirded out by the quotes. Will re-enable and suck it up. Thanks!

    On Tue, Apr 14, 2015 at 9:20 AM, Jan Aagaard Meier <[email protected]

    wrote:

    Well in that case there is really nothing to do - you have told sequelize
    that you don't want quotes, so you're not getting any :)

    quoteIdentifiers should really only be used in legacy situations where
    the table was created without quotes. When everything is handled by
    sequelize, quotes is your friend ;)

    —
    Reply to this email directly or view it on GitHub
    #3528 (comment)
    .

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions