Issue Creation Checklist
Bug Description
It is impossible to create an Anonymous disk-based database using Sequelize.
SSCCE
new Sequelize({dialect: 'sqlite', storage: ''})
What do you expect to happen?
The empty string in the storage parameter should have been passed to sqlite3, which sqlite3 documentation says ought to create an
anonymous disk-based database
which will be automatically deleted when the handle is closed.
What is actually happening?
An in-memory SQLite database is created
Additional context
Looking in the source code, the storage parameter is part of a chain of || (logic or operator)s. This is a common JS shorthand for picking the rightmost value that isn't falsy. Unfortunately an '' (empty string) is also falsy, which causes Sequelize to keep going right and picking something else that isn't falsy.
For example, in /lib/dialects/sqlite/connection-manager:48 we have this.sequelize.options.storage || this.sequelize.options.host || ':memory:'. Here if storage is empty string it will pick either host or ':memory:'.
Environment
- Sequelize version: 6.5.0
- Node.js version: v14.15.0
Bug Report Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
Issue Creation Checklist
Bug Description
It is impossible to create an Anonymous disk-based database using Sequelize.
SSCCE
What do you expect to happen?
The empty string in the
storageparameter should have been passed to sqlite3, which sqlite3 documentation says ought to create anWhat is actually happening?
An in-memory SQLite database is created
Additional context
Looking in the source code, the
storageparameter is part of a chain of||(logic or operator)s. This is a common JS shorthand for picking the rightmost value that isn't falsy. Unfortunately an''(empty string) is also falsy, which causes Sequelize to keep going right and picking something else that isn't falsy.For example, in /lib/dialects/sqlite/connection-manager:48 we have
this.sequelize.options.storage || this.sequelize.options.host || ':memory:'. Here ifstorageis empty string it will pick eitherhostor':memory:'.Environment
Bug Report Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?