How does knex handle default values in SQLite? How does knex handle default values in SQLite? sql sql

How does knex handle default values in SQLite?


I'm learning knex.js so I can use it in a project involving PostgreSQL. While trying out Sqlite I came across this issue.

Turns out it's documented!

If one prefers that undefined keys are replaced with NULL instead of DEFAULT one may give useNullAsDefault configuration parameter in knex config.

And they give this code:

var knex = require('knex')({  client: 'sqlite3',  connection: {     filename: "./mydb.sqlite"  },  useNullAsDefault: true});knex('coords').insert([{x: 20}, {y: 30}, {x: 10, y: 20}])// insert into `coords` (`x`, `y`) values (20, NULL), (NULL, 30), (10, 20)"

This removed the warning message for me.