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

Same boolean handling in better-sqlite3 as in sqlite3 #4982

Merged
merged 2 commits into from
Jan 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/dialects/better-sqlite3/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class Client_BetterSQLite3 extends Client_SQLite3 {
}

if (typeof binding === 'boolean') {
return String(binding);
return Number(binding);
}

return binding;
Expand Down
16 changes: 16 additions & 0 deletions test/integration2/schema/misc.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,22 @@ describe('Schema (misc)', () => {
'create index "10_test_table_logins_index" on "10_test_table" ("logins")',
]);
}));

it('test boolean type with sqlite3 and better sqlite3 #4955', async function () {
if (!isSQLite(knex)) {
this.skip();
}
await knex.schema
.dropTableIfExists('test')
.createTable('test', (table) => {
table.boolean('value').notNullable();
});

await knex('test').insert([{ value: true }, { value: false }]);
const data = await knex('test').select();
expect(data[0].value).to.eq(1);
expect(data[1].value).to.eq(0);
});
});

describe('table', () => {
Expand Down