Skip to content

Commit

Permalink
allow falsy default values on sqlite
Browse files Browse the repository at this point in the history
  • Loading branch information
koskimas committed Jul 4, 2022
1 parent f2715be commit 18506c0
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 19 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "kysely",
"version": "0.19.7",
"version": "0.19.8",
"description": "Type safe SQL query builder",
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion src/dialect/sqlite/sqlite-introspector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})),
}
}
Expand Down
28 changes: 11 additions & 17 deletions test/node/src/schema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1066,36 +1066,33 @@ 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: {
sql: `create schema "pets"`,
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: {
sql: `create schema if not exists "pets"`,
parameters: [],
},
mysql: {
sql: "create schema if not exists `pets`",
sql: 'create schema if not exists `pets`',
parameters: [],
},
sqlite: NOT_SUPPORTED,
Expand All @@ -1116,38 +1113,35 @@ 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: {
sql: `drop schema "pets"`,
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: {
sql: `drop schema if exists "pets"`,
parameters: [],
},
mysql: {
sql: "drop schema if exists `pets`",
sql: 'drop schema if exists `pets`',
parameters: [],
},
sqlite: NOT_SUPPORTED,
Expand Down

0 comments on commit 18506c0

Please sign in to comment.