Skip to content

sqlite: enable foreign key constraints by default

For historical reasons and to maintain compatibility with legacy database schemas, SQLite does not enable foreign key constraints by default. For new applications, however, this behavior is undesirable. Currently, any application that wishes to use foreign keys must use

PRAGMA foreign_keys = ON;

to explicitly enable enforcement of such constraints.

This commit changes the behavior of the SQLite API built into Node.js to enable foreign key constraints by default. This behavior can be overridden by users to maintain compatibility with legacy database schemas.

I decided against using the compile-time option to set the default behavior to avoid limiting compatibility with third-party code that links against node's copy of SQLite.

Merge request reports

Loading