You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Knex version: 3.1.0
Database + version: Sqlite 3.42.0
Client + version: sqlite3 ^5.1.7 / better-sqlite3 ^9.2.2
OS: Linux Mint 21.3
Bug
Accodrding to the docs (https://knexjs.org/guide/schema-builder.html#decimal) this should create a column of type decimal
but it creates a column of type float not decimal (Tested with sqlite database and with both clients)
Reduced test code:
importknexfrom'knex';constdb=knex({client: 'sqlite3',connection: {filename: '/db.sqlite3'},debug: true,asyncStackTraces: true,log: {warn(message){console.log(`Warning from knex: ${message}`);},error(message){console.log(`Error from knex: ${message}`);},deprecate(message){console.log(`Deprecate from knex: ${message}`);},debug(message){console.log(`Debug from knex stringified: ${JSON.stringify(message)}`);},},migrations: {tableName: 'migrations'},useNullAsDefault: true});consttest=async()=>{awaitdb.schema.table('testTable',async(table)=>{table.decimal('newCol',6,2);});returntrue;};test().then(()=>{console.log('created');process.exit(0);});
and what is shown in terminal:
Debug from knex stringified: [{"sql":"alter table `testTable` add column `newCol` float","bindings":[]}]
created
Notice the Debug result in terminal where you can find it uses "float" and not "decimal"
The text was updated successfully, but these errors were encountered:
Hey @rluvaton
I found that in sqlit3 column compiler double, decimal, and floating are all converted to float.
I think sqlite3 supports all three types, I can change that and create a PR. But is there a reason for this behaviour?
Environment
Knex version: 3.1.0
Database + version: Sqlite 3.42.0
Client + version: sqlite3 ^5.1.7 / better-sqlite3 ^9.2.2
OS: Linux Mint 21.3
Bug
Accodrding to the docs (https://knexjs.org/guide/schema-builder.html#decimal) this should create a column of type decimal
but it creates a column of type float not decimal (Tested with sqlite database and with both clients)
Reduced test code:
and what is shown in terminal:
Notice the Debug result in terminal where you can find it uses "float" and not "decimal"
The text was updated successfully, but these errors were encountered: