Repository navigation
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
WikiRik
left a comment
There was a problem hiding this comment.
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.
I used this feature! I'm disappointed (and a little bit terrified 😅) that it's been removed without any alternative provided. Please bring it back! |
|
Also calling out that this PR breaks the following example since we shouldn't be using the |
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 thedialectfield insteadoptions.databaseVersion: users should usegetDatabaseVersioninsteadoptions.hooks: Is a shortcut for calling.hooks.addListeneroptions.models: Is a shortcut for calling.addModelsoptions.pool: The options are available onsequelize.poolinsteadAbstractDialect.getDefaultPorthas 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
loggingoption disallowtruein typingssequelize.setDatabaseVersionwhich 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.tswas mostly disabled due to the test not actually testing anything, see Drop subclasses ofSequelizeConnectionError#17240abstract/connection-manager.test.tswere moved topool.test.ts(split between integration & unit)List of Breaking Changes
"url"option.dialectOptionsoption 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.poolsequelize.configfield 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.optionsis now fully frozen. It is no longer possible to modify the Sequelize options after the instance has been created.sequelize.optionsis 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.sqlitein your current working directory.':memory:'or''requires configuring the pool to behave like a singleton, and disallowed read replicationmatchoption is no longer supported bysequelize.sync. If you made use of this feature, let us know so we can design a better alternative.