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
feat: type options per dialect, add "url" option, remove alternative Sequelize constructor signatures #17222
Conversation
I'm reading as much as I can on SQLite pooling and the documentation is pretty clear about the fact that we can have multiple concurrent read connections, but only one connection can write at a time With that in mind, I think SQLite should use the pool like all other dialects, but:
|
… into ephys/option-rewrite
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Few minor remarks
Don't forget to add the list of breaking changes to the commit when merging, using the conventional commit syntax |
…Sequelize constructor signatures (#17222) BREAKING CHANGE: The sequelize constructor only accepts a single parameter: the option bag. All other signatures have been removed. BREAKING CHANGE: Setting the sequelize option to a string representing a URL has been replaced with the `"url"` option. BREAKING CHANGE: The `dialectOptions` option has been removed. All options that were previously in that object can now be set at the root of the option bag, like all other options. BREAKING CHANGE: All dialect-specific options changed. This includes at least some credential options that changed. BREAKING CHANGE: Which dialect-specific option can be used is allow-listed to ensure they do not break Sequelize BREAKING CHANGE: The sequelize pool is not on the connection manager anymore. It is now directly on the sequelize instance and can be accessed via `sequelize.pool` BREAKING CHANGE: The `sequelize.config` field has been removed. Everything related to connecting to the database has been normalized to `sequelize.options.replication.write` (always present) and `sequelize.options.replication.read` (only present if read-replication is enabled) BREAKING CHANGE: `sequelize.options` is now fully frozen. It is no longer possible to modify the Sequelize options after the instance has been created. BREAKING CHANGE: `sequelize.options` is a normalized list of option. If you wish to access the options that were used to create the sequelize instance, use `sequelize.rawOptions` BREAKING CHANGE: The default sqlite database is not `':memory:'` anymore, but `sequelize.sqlite` in your current working directory. BREAKING CHANGE: Setting the sqlite database to a temporary database like `':memory:'` or `''` requires configuring the pool to behave like a singleton, and disallowed read replication BREAKING CHANGE: The `match` option is no longer supported by `sequelize.sync`. If you made use of this feature, let us know so we can design a better alternative.
Note
Please review #17219 first
Description of Changes
The initial goal was to remove the extra signatures from the Sequelize constructor, and add the "url" option.
To do these changes cleanly, I moved the constructor to the TypeScript implementation.
Of course, and this is where I'm sorry, that lead to a series of changes to make the constructor TypeScript-compatible. Here they are:
options.dialect
: users should access thedialect
field insteadoptions.databaseVersion
: users should usegetDatabaseVersion
insteadoptions.hooks
: Is a shortcut for calling.hooks.addListener
options.models
: Is a shortcut for calling.addModels
options.pool
: The options are available onsequelize.pool
insteadAbstractDialect.getDefaultPort
has been removed because port normalization is now done by the dialect themselves, as connection options differ wildly per dialectoptions
,config
,replication
)Sequelize throws if an unknown option is used:
Important
With this PR, the URL parsing is broken because it does not produce the right options for every dialect. We need to fix that before we publish a release.
I would rather not do it in this PR considering how big this PR already is.
Misc changes
logging
option disallowtrue
in typingssequelize.setDatabaseVersion
which does the database version checksequelize.sync
's options does not inherit from sequelize's options anymore, as they caused problems with schemas. They still inherit fromsequelize.options.sync
.sequelize.sync
: It only worked for databases that have a "database" option. A better alternative should be considered insteadChanges made to tests
integration/configuration.test.ts
was mostly disabled due to the test not actually testing anything, see Drop subclasses ofSequelizeConnectionError
#17240abstract/connection-manager.test.ts
were moved topool.test.ts
(split between integration & unit)List of Breaking Changes
"url"
option.dialectOptions
option has been removed. All options that were previously in that object can now be set at the root of the option bag, like all other options.sequelize.pool
sequelize.config
field has been removed. Everything related to connecting to the database has been normalized tosequelize.options.replication.write
(always present) andsequelize.options.replication.read
(only present if read-replication is enabled)sequelize.options
is now fully frozen. It is no longer possible to modify the Sequelize options after the instance has been created.sequelize.options
is a normalized list of option. If you wish to access the options that were used to create the sequelize instance, usesequelize.rawOptions
':memory:'
anymore, butsequelize.sqlite
in your current working directory.':memory:'
or''
requires configuring the pool to behave like a singleton, and disallowed read replicationmatch
option is no longer supported bysequelize.sync
. If you made use of this feature, let us know so we can design a better alternative.