Skip to content

Commit

Permalink
Fix a bug with sqllite default values and inserts (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
jondlm committed Jun 6, 2021
1 parent 0b5823b commit 2508bca
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/builders/schema.js
Expand Up @@ -184,7 +184,13 @@ const build = db => {
type,
args: makeCreateArgs(model),
resolve: async (obj, values, info) => {
const thing = await model.create(values);
const options = {
// By default sequelize will insert all columns which can cause a
// bug where default values, that use functions, defined at the
// database layer don't get populated correctly.
fields: Object.keys(values),
};
const thing = await model.create(values, options);
return thing;
},
};
Expand Down

0 comments on commit 2508bca

Please sign in to comment.