From 18506c075ff53e07755551dbb10c6b275418f07b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sami=20Koskim=C3=A4ki?= Date: Mon, 4 Jul 2022 12:35:09 +0300 Subject: [PATCH] allow falsy default values on sqlite --- package.json | 2 +- src/dialect/sqlite/sqlite-introspector.ts | 2 +- test/node/src/schema.test.ts | 28 +++++++++-------------- 3 files changed, 13 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index b5bc61c62..33aabfafe 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "kysely", - "version": "0.19.7", + "version": "0.19.8", "description": "Type safe SQL query builder", "repository": { "type": "git", diff --git a/src/dialect/sqlite/sqlite-introspector.ts b/src/dialect/sqlite/sqlite-introspector.ts index a41cfc809..d24f830b7 100644 --- a/src/dialect/sqlite/sqlite-introspector.ts +++ b/src/dialect/sqlite/sqlite-introspector.ts @@ -89,7 +89,7 @@ export class SqliteIntrospector implements DatabaseIntrospector { dataType: col.type, isNullable: !col.notnull, isAutoIncrementing: col.name === autoIncrementCol, - hasDefaultValue: !!col.dflt_value, + hasDefaultValue: col.dflt_value != null, })), } } diff --git a/test/node/src/schema.test.ts b/test/node/src/schema.test.ts index d8ab116db..95098a56f 100644 --- a/test/node/src/schema.test.ts +++ b/test/node/src/schema.test.ts @@ -1066,8 +1066,7 @@ for (const dialect of BUILT_IN_DIALECTS) { afterEach(cleanup) it('should create a schema', async () => { - const builder = ctx.db.schema - .createSchema('pets') + const builder = ctx.db.schema.createSchema('pets') testSql(builder, dialect, { postgres: { @@ -1075,19 +1074,17 @@ for (const dialect of BUILT_IN_DIALECTS) { parameters: [], }, mysql: { - sql: "create schema `pets`", + sql: 'create schema `pets`', parameters: [], }, - sqlite: NOT_SUPPORTED + sqlite: NOT_SUPPORTED, }) await builder.execute() }) it('should create a schema if not exists', async () => { - const builder = ctx.db.schema - .createSchema('pets') - .ifNotExists() + const builder = ctx.db.schema.createSchema('pets').ifNotExists() testSql(builder, dialect, { postgres: { @@ -1095,7 +1092,7 @@ for (const dialect of BUILT_IN_DIALECTS) { parameters: [], }, mysql: { - sql: "create schema if not exists `pets`", + sql: 'create schema if not exists `pets`', parameters: [], }, sqlite: NOT_SUPPORTED, @@ -1116,10 +1113,9 @@ for (const dialect of BUILT_IN_DIALECTS) { afterEach(cleanup) it('should create a schema', async () => { - await ctx.db.schema.createSchema('pets').execute(); + await ctx.db.schema.createSchema('pets').execute() - const builder = ctx.db.schema - .dropSchema('pets') + const builder = ctx.db.schema.dropSchema('pets') testSql(builder, dialect, { postgres: { @@ -1127,19 +1123,17 @@ for (const dialect of BUILT_IN_DIALECTS) { parameters: [], }, mysql: { - sql: "drop schema `pets`", + sql: 'drop schema `pets`', parameters: [], }, - sqlite: NOT_SUPPORTED + sqlite: NOT_SUPPORTED, }) await builder.execute() }) it('should drop a schema if exists', async () => { - const builder = ctx.db.schema - .dropSchema('pets') - .ifExists() + const builder = ctx.db.schema.dropSchema('pets').ifExists() testSql(builder, dialect, { postgres: { @@ -1147,7 +1141,7 @@ for (const dialect of BUILT_IN_DIALECTS) { parameters: [], }, mysql: { - sql: "drop schema if exists `pets`", + sql: 'drop schema if exists `pets`', parameters: [], }, sqlite: NOT_SUPPORTED,