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

Hook-generated updates to STRING values are not applied to the database #13157

Open
2 of 6 tasks
daweimau opened this issue Mar 30, 2021 · 3 comments
Open
2 of 6 tasks

Comments

@daweimau
Copy link

daweimau commented Mar 30, 2021

Issue Description

When model.save() triggers a hook that updates an instance STRING value, Sequelize does not apply this to database. The resulting query does not attempt to update this field.

However, Sequelize does update the javascript model instance.

This is extremely misleading at best: the app believes the database field has been updated, when actually the database field has not changed.

What are you doing?

Here is the link to the SSCCE for this issue: sequelize/sequelize-sscce#154

NB: Some of the test executions "pass", but it looks like that is only because the SSCCE repo is sometimes running dummy tests instead of the real SSCCE code.

What do you expect to happen?

If a hook fires and includes code to update a field, the field should be updated and that update should be persisted to the database via the UPDATE query.

OR: at the very least, the model instance should remain consistent with Sequelize-facilitated database updates. The instance should never stay divergent after .save(), as it does in the SCCE.

What is actually happening?

When using:

  • at least STRING datatypes, and
  • beforeValidate or beforeUpdate hooks,

The field is not updated in the database (UPDATE query does not include the hook-generated update). But the sequelize instance is updated.

Additional context

Add any other context or screenshots about the feature request here.

Environment

  • Sequelize version: 6.3.3
  • Node.js version: 12.20.0
  • Operating System: docker-alpine, running on Mac OS Big Sur 11.1

Issue Template Checklist

How does this problem relate to dialects?

  • I think this problem happens regardless of the dialect.
  • I think this problem happens only for the following dialect(s):
  • I don't know, I was using PUT-YOUR-DIALECT-HERE, with connector library version XXX and database version XXX

The SSCCE testing results show mixed failures and it is unclear which of these (if any) really reflect dialect differences or just issues with the SSCCE repo.

Would you be willing to resolve this issue by submitting a Pull Request?

  • Yes, I have the time and I know how to start.
  • [] Yes, I have the time but I don't know how to start, I would need guidance.
  • No, I don't have the time, although I believe I could do it if I had the time...
  • No, I don't have the time and I wouldn't even know how to start.

This SSCCE is about the limits of my ability, sorry.

@daweimau

This comment was marked as resolved.

@github-actions github-actions bot removed the stale label Oct 29, 2021
@github-actions github-actions bot added the stale label Nov 6, 2021
@mooncfrat2019

This comment was marked as resolved.

@github-actions github-actions bot removed the stale label Nov 11, 2021
@github-actions github-actions bot added the stale label Nov 26, 2021
@WikiRik WikiRik added type: bug and removed stale labels Nov 26, 2021
@DanielJRaine

This comment was marked as resolved.

@sequelize sequelize deleted a comment from github-actions bot Mar 18, 2024
@sequelize sequelize deleted a comment from github-actions bot Mar 18, 2024
@sequelize sequelize deleted a comment from github-actions bot Mar 18, 2024
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

4 participants