Skip to content

Extract dialects out of the core #13722

Open

Description

@sdepold

In order to support additional dialects more easily in the future, we want to pull the dialect specific files out of the core and move them into dedicated npm modules.

Relates to sequelize/meetings#2

### Current Progress
- [x] Decide on the API
- [x] Can we have the same set of tests for all built-in dialects?
- [x] https://github.com/sequelize/sequelize/pull/17198
- [ ] https://github.com/sequelize/sequelize/pull/17206
- [x] https://github.com/sequelize/sequelize/pull/17202
- [x] https://github.com/sequelize/sequelize/pull/17190
- [x] https://github.com/sequelize/sequelize/pull/17205
- [ ] https://github.com/sequelize/sequelize/pull/17207
- [ ] https://github.com/sequelize/sequelize/pull/17209
- [x] https://github.com/sequelize/sequelize/pull/17197
- [ ] https://github.com/sequelize/sequelize/pull/17216
- [ ] https://github.com/sequelize/sequelize/pull/17219
- [ ] https://github.com/sequelize/sequelize/pull/17222
- [ ] https://github.com/sequelize/sequelize/pull/17252
- [ ] https://github.com/sequelize/website/pull/742
- [ ] https://github.com/sequelize/sequelize/pull/17269
- [ ] Require the dialect class to be provided instead of a dialect name
- [ ] Add a README.md to all packages

Activity

  1. added this to the v7 milestone on Nov 29, 2021
  2. added
    breaking change
    type: refactor
    on Nov 29, 2021
  3. removed this from the v7 milestone on Oct 23, 2022
  4. pinned this issue on Mar 20, 2024
  5. ephys commented on Mar 20, 2024

    @ephys
    Member

    We're finally working on this

    The high level plan is to have individual packages for each dialect, such as @sequelize/postgres, @sequelize/mariadb, @sequelize/oracle, etc

    Each package will provide all the dialect-specific code. This means that it will be much easier for the community to create third-party dialect packages, even though they would currently still need to use many unstable internal APIs. This second part is something we'll improve in the future by providing a clean public dialect API, such as @sequelize/core/dialect-toolbox

    Each package will also include the relevant connector library (pg, mariadb, tedious, etc). Users won't have to figure out which version should be installed anymore.

    Finally, the dialect-specific options will be better checked in both typing and runtime checks

    When initializing Sequelize, users will now need to provide the dialect package instead of a dialect name. Here is what it would look like:

    import { PostgresDialect } from '@sequelize/postgres';
    
    new Sequelize({
      dialect: PostgresDialect,
      // dialect-specific options
      username: 'demo',
      password: 'demo',
      native: true,
    
      // sequelize options
      pool: { max: 5 },
    });

    In this version, all options are provided to Sequelize itself. Sequelize then picks the ones that are dialect specific and gives them to the dialect instance when initializing it.

    The dialectOptions option would be removed. All dialect-specific options would be moved to the top-level option bag.

    The dialect would expose a static method called getSupportedOptions that is used to:

    • Make sure all user-provided options are supported by either Sequelize or the dialect
    • Make sure no dialect-specific option conflicts with Sequelize

    Because credentials are dialect-specific, we need to change the signature of the constructor to only accept an option bag. The old new Sequelize(database, username, password) one does not make sense for some dialects.

  6. unpinned this issue on Mar 20, 2024
  7. jdgriffith commented on Mar 21, 2024

    @jdgriffith

    I believe this is a great direction to take this. Will this apply to v6 or is this a v7 initiative?

  8. WikiRik commented on Mar 21, 2024

    @WikiRik
    Member

    This is a v7 initiative, and will also continue on in v8 most likely

  9. jdgriffith commented on Mar 21, 2024

    @jdgriffith

    v7 I think* has been worked for the last two years if I'm not mistaken. Do we think v7 will reach a stable release in the foreseeable future?

  10. WikiRik commented on Mar 22, 2024

    @WikiRik
    Member

    We've discussed the release of v7 today with our core team. The v7 alphas are already quite stable. After the initial extraction of dialects we want to move into a beta phase for v7 while we work on updating CLI and help bigger third-party packages migrate to v7. During that beta phase we will be more careful about breaking changes that we add.
    See more here; https://github.com/sequelize/meetings/wiki/Meeting-2024%E2%80%9003%E2%80%9022#latest-v7-release-plan

    Doing this work on v6 is counterproductive and requires a lot more work for us.

  11. ephys commented on Mar 28, 2024

    @ephys
    Member

    @WikiRik for the task about updating the documentation, note that we now have this project to keep track of which PRs still need to be documented: PRs & Issues to document on website

  12. ephys commented on Mar 28, 2024

    @ephys
    Member

    If we're going to add support for better-sqlite3, maybe we should rename the @sequelize/sqlite to @sequelize/sqlite3 to reflect the name of the library that is used by it. We'd then be able to add @sequelize/better-sqlite3

  13. WikiRik commented on Mar 28, 2024

    @WikiRik
    Member

    If we're going to add support for better-sqlite3, maybe we should rename the @sequelize/sqlite to @sequelize/sqlite3 to reflect the name of the library that is used by it. We'd then be able to add @sequelize/better-sqlite3

    Bit more verbose, but I was also thinking about @sequelize/sqlite/better-sqlite possibly. Users shouldn't need to care which adapter they use, but if they have a preference they can use another one we provide. Alternatively both @sequelize/sqlite and @sequelize/better-sqlite would also be fine with me. I like @sequelize/sqlite less because it forces us towards an implementation and not just the dialect name

  14. ephys commented on Mar 28, 2024

    @ephys
    Member

    The problem with @sequelize/sqlite/better-sqlite is that it requires installing both dialect libraries. If we want to deduplicate code between the two, we can just publish @sequelize/abstract-sqlite that is not connector-dependant

    Users shouldn't need to care which adapter they use

    If we start proposing multiple adapters, they should make an informed decision on which one they want to use. Otherwise, we'd just pick the one we consider to be the best. Naming one /sqlite indicates that it's the one users should use by default, when instead we should document the differences

  15. WikiRik commented on Mar 28, 2024

    @WikiRik
    Member

    If we start proposing multiple adapters, they should make an informed decision on which one they want to use. Otherwise, we'd just pick the one we consider to be the best. Naming one /sqlite indicates that it's the one users should use by default, when instead we should document the differences

    You've got a point there. Do we want to do this for the other dialects as well or is this only for sqlite since there is a relatively big demand to support better-sqlite?

  16. ephys commented on Mar 28, 2024

    @ephys
    Member

    To be consistent, we probably should. Considering the demand has only ever been for sqlite, that may not be worth the trouble.

  17. ephys commented on Mar 28, 2024

    @ephys
    Member

    Following the changes done in #17222, it will be very important to have a clear page that explains how to configure the credentials per dialect. Right now it's in the "dialect specific things" page, which is a bit too buried for my liking. The "how to connect to your database" chapter should probably go at the very start of the documentation, right after "getting started" and before "defining models". I think it would make sense to have one page per dialect that first gives the basics of connecting to that database type, and has sub-chapters for other dialect-specific options

    The other dialect-specific things on that page should probably be moved to where they can be used too, so that page could be deleted

  18. ephys commented on Apr 8, 2024

    @ephys
    Member

    Considering DB2 is really DB2 for Linux, Unix, Windows, and ibmi is really DB2 for IBM i, should we rename the packages to @sequelize/db2-luw and @sequelize/db2-ibmi respectively?

    Following discussion with @WikiRik, based on IBM's branding, they should be @sequelize/db2 and @sequelize/db2-ibmi

  19. removed
    type: refactor
    on Mar 9, 2025
  20. added theissue type on Mar 9, 2025
  21. reopened this on Mar 9, 2025
  22. WikiRik commented on Mar 9, 2025

    @WikiRik
    Member

    Re-opening this since not all tasks have been completed, per the initial post

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    breaking change

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions