Skip to content

increment function generates strange sql #9572

Closed

Description

@fareshan

I am trying to increment a field:
user.increment({ lastCheckingEmailSendingNumber: 1 });
The increment operation does not work. And I get this error:
error.message: "column "0" of relation "User" does not exist"
error.sql: "UPDATE "User" SET "lastCheckingEmailSendingNumber"="lastCheckingEmailSendingNumber"+ 1,"0"='id',"1"='email',"2"='firstName',"3"='lastName',"4"='phoneNumber',"5"='birthdate',"6"='nationalId' WHERE "id" = 1 RETURNING *"

I don't understand where this part "0"='id',"1"='email',"2"='firstName',"3"='lastName',"4"='phoneNumber',"5"='birthdate',"6"='nationalId'
comes from, even though emai, firstName, ... are columns in User Table !?

I am using sequelize-typescript version 0.6.5

Dialect: postgres
Dialect version: pg 6.4.2
Database version: 9.6
Sequelize version: 5.0.0-beta.8
Tested with latest release: yes, 5.0.0-beta.8

Activity

  1. kayorl commented on Jul 3, 2018

    @kayorl

    same problem.

  2. sushantdhiman commented on Jul 3, 2018

    @sushantdhiman
    Contributor

    Please use Github Issue Tracker only for reporting bugs, requesting new features or discussions. Ask questions on Stackoverflow sequelize.js tag or Slack. While I would like to help answer any questions but it still take too much time.

    If you are reporting a bug please isolate it as SSCCE, present it nicely and follow issue template. This will help maintainers and contributors understand your issue quickly.

    If you are requesting a feature spend some time to properly present your use case with some examples, current and expected outcome.

    ( What is SSCCE ? You can find template for Sequelize here )

    A few good example of SSCCE

    1. ResourceRequest timed out - connection not reestablished after db restarted #8014 (comment)
    2. removeAttribute('id') results in undefined: null data value #7318 (comment)
    3. toJSON converting booleans to "t" (true) or "f" (false) #8749 (comment)
  3. fareshan commented on Jul 3, 2018

    @fareshan
    Author

    @sushantdhiman
    It is a bug.
    And I followed the template.

  4. sushantdhiman commented on Jul 4, 2018

    @sushantdhiman
    Contributor

    @fareshan I am not closing issues randomly, I see nothing in your issue report that could help me reproduce this issue. If you want to report an issue or seeking help, atleast try to present a proper example or even better a SSCCE

  5. lessu commented on May 7, 2019

    @lessu

    It seems it have something to do with DefaultScope.attributes.exclude.
    after removed exclude,no error shows any more

  6. fareshan commented on May 8, 2019

    @fareshan
    Author

    @lessu That was a year ago. I don't remember how I fixed it. But I just looked to the code and I see that I am using user.increment("lastCheckingEmailSendingNumber", { by: 1 }); instead of user.increment({ lastCheckingEmailSendingNumber: 1 });
    So I fixed it with this change or by updating Sequelize.

    And Thanks for your help.

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