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

Fix a bug with sqllite default values and inserts #34

Merged
merged 1 commit into from
Jun 6, 2021

Conversation

jondlm
Copy link
Contributor

@jondlm jondlm commented Apr 24, 2020

I found a bug where sequelize was incorrectly inserting a raw string when it should have been respecting the default defined at the database column level. This PR fixes it by reducing the fields that sequelize inserts to to only those defined on the values.

Here's a repro. Make a table like this:

CREATE TABLE accounts (
  "id"                  TEXT PRIMARY KEY,
  "name"                TEXT NOT NULL,
  "created"             TEXT DEFAULT (strftime('%Y-%m-%dT%H:%M:%SZ')),
) WITHOUT ROWID;

And try to insert just a record with just a "name". You'll end up with the literal strftime('%Y-%m-%dT%H:%M:%SZ') for the created column.

@bradleyboy
Copy link
Owner

Way late but thanks for this 🙏

@bradleyboy bradleyboy merged commit 2508bca into bradleyboy:master Jun 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants