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

Updated sqlite3 and better-sqlite3 to use more accurate numeric types #6063

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
7 changes: 3 additions & 4 deletions lib/dialects/sqlite3/schema/sqlite-columncompiler.js
Expand Up @@ -37,10 +37,9 @@ class ColumnCompiler_SQLite3 extends ColumnCompiler {

ColumnCompiler_SQLite3.prototype.json = 'json';
ColumnCompiler_SQLite3.prototype.jsonb = 'json';
ColumnCompiler_SQLite3.prototype.double =
ColumnCompiler_SQLite3.prototype.decimal =
ColumnCompiler_SQLite3.prototype.floating =
'float';
ColumnCompiler_SQLite3.prototype.double = 'double'
ColumnCompiler_SQLite3.prototype.decimal = 'decimal'
ColumnCompiler_SQLite3.prototype.floating = 'float';
ColumnCompiler_SQLite3.prototype.timestamp = 'datetime';
// autoincrement without primary key is a syntax error in SQLite, so it's necessary
ColumnCompiler_SQLite3.prototype.increments =
Expand Down
19 changes: 16 additions & 3 deletions test/unit/schema-builder/better-sqlite3.js
Expand Up @@ -755,6 +755,7 @@ describe('BetterSQLite3 SchemaBuilder', function () {
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
});


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove

it('adding double', function () {
tableSql = client
.schemaBuilder()
Expand All @@ -764,7 +765,19 @@ describe('BetterSQLite3 SchemaBuilder', function () {
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
equal(tableSql[0].sql, 'alter table `users` add column `foo` double');
});

it('adding double, no precision', function () {
tableSql = client
.schemaBuilder()
.table('users', function (table) {
table.double('foo', null);
})
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` double');
});

it('adding decimal', function () {
Expand All @@ -776,7 +789,7 @@ describe('BetterSQLite3 SchemaBuilder', function () {
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
equal(tableSql[0].sql, 'alter table `users` add column `foo` decimal');
});

it('test adding decimal, no precision', function () {
Expand All @@ -788,7 +801,7 @@ describe('BetterSQLite3 SchemaBuilder', function () {
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
equal(tableSql[0].sql, 'alter table `users` add column `foo` decimal');
});

it('adding boolean', function () {
Expand Down
18 changes: 15 additions & 3 deletions test/unit/schema-builder/sqlite3.js
Expand Up @@ -815,7 +815,19 @@ describe('SQLite SchemaBuilder', function () {
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
equal(tableSql[0].sql, 'alter table `users` add column `foo` double');
});

it('adding double, no precision', function () {
tableSql = client
.schemaBuilder()
.table('users', function (table) {
table.double('foo', null);
})
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` double');
});

it('adding decimal', function () {
Expand All @@ -827,7 +839,7 @@ describe('SQLite SchemaBuilder', function () {
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
equal(tableSql[0].sql, 'alter table `users` add column `foo` decimal');
});

it('test adding decimal, no precision', function () {
Expand All @@ -839,7 +851,7 @@ describe('SQLite SchemaBuilder', function () {
.toSQL();

equal(1, tableSql.length);
equal(tableSql[0].sql, 'alter table `users` add column `foo` float');
equal(tableSql[0].sql, 'alter table `users` add column `foo` decimal');
});

it('adding boolean', function () {
Expand Down