From 2508bca25f11aa6d2bdc34c73f2f57bcca4ae0b4 Mon Sep 17 00:00:00 2001 From: Jon de la Motte Date: Sun, 6 Jun 2021 10:07:35 -0700 Subject: [PATCH] Fix a bug with sqllite default values and inserts (#34) --- src/builders/schema.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/builders/schema.js b/src/builders/schema.js index 949e2f5..304040f 100644 --- a/src/builders/schema.js +++ b/src/builders/schema.js @@ -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; }, };