Skip to content

feat(core): Drop the ability to specify the dialect as a string - #18204

Merged
WikiRik merged 8 commits into
mainfrom
ephys/drop-require-dialect
Apr 12, 2026
Merged

WikiRik merged 8 commits into
mainfrom
ephys/drop-require-dialect

Conversation

@ephys

@ephys ephys commented Apr 6, 2026 •

Copy link
Copy Markdown
Member

Pull Request Checklist

  • Have you added new tests to prevent regressions?
  • If a documentation update is necessary, have you opened a PR to the documentation repository?
  • Did you update the typescript typings accordingly (if applicable)?
  • Does the description below contain a link to an existing issue (Closes #[issue]) or a description of the issue you are solving?
  • Does the name of your PR follow our conventions?

Description of Changes

The goal is to improve the ability to bundle code that uses Sequelize, by not requiring modules that might not be installed.

To do that, I dropped the ability to set the the dialect Sequelize constructor option to a string. Users already need to change their connection options because they depend on the dialect now, so there is no real reason to keep the legacy dialect option. I think it even hurts TypeScript users to keep it, because they don't get proper option typings if they specify a dialect string instead of a dialect class.

The CLI still supports dialect strings thanks to this PR: #18193

Note: The ability to bundle Sequelize is still not perfect, as we still dynamically require moment.

List of Breaking Changes

The dialect option of the Sequelize constructor now must be a Dialect class. It cannot be a string anymore, and Sequelize will not require the Dialect class automatically.

Summary by CodeRabbit

  • Refactor

    • Dialect initialization simplified: constructors now require a dialect class and validate it at runtime.
    • Internal modules modernized to ES modules and validation utilities consolidated into a single Validator API with extended helper methods.
  • Bug Fixes

    • Corrected STRING length validation behavior for the Oracle dialect.

@coderabbitai

coderabbitai Bot commented Apr 6, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: da0da1bf-bca9-43b9-ad4d-d3a3acee9173

📥 Commits

Reviewing files that changed from the base of the PR and between 99cb236 and 07cd371.

📒 Files selected for processing (1)
  • packages/core/test/support.ts

📝 Walkthrough

Walkthrough

Removed string-union dialect typing and the runtime string→class dialect resolver; dialects must now be provided as classes. Converted several CommonJS imports to ESM, refactored validator utilities into a new Validator export, and updated tests and helpers to use local dialect-name typings and class-only dialect handling.

Changes

Cohort / File(s) Summary
Dialect types & bootstrap
packages/core/src/abstract-dialect/dialect.ts, packages/core/src/sequelize.d.ts, packages/core/src/sequelize.internals.ts, packages/core/src/sequelize-typescript.ts
Removed SUPPORTED_DIALECTS/DialectName; changed dialect name type to string; removed importDialect; EphemeralSequelizeOptions.dialect now requires a dialect class and runtime-checks that options.dialect is a function.
Imports & query generator
packages/core/src/abstract-dialect/query-generator.js
Converted several CommonJS require calls to ESM imports (inspect, crypto, DataTypes, errors, operators, _validateIncludedElements) and replaced util.inspect usage with ESM inspect.
Validator refactor (runtime & types)
packages/core/src/utils/validator-extras.ts, packages/core/src/utils/validator-extras.js, packages/core/src/utils/validator-extras.d.ts, packages/core/src/instance-validator.js, packages/core/src/abstract-dialect/data-types.ts, packages/core/src/geo-json.ts, packages/core/src/sequelize.js, packages/core/src/index.mjs
Rewrote validator module into a TypeScript Validator export with many helper methods and extend; removed old .d.ts declaration; updated consumers to import the new Validator binding.
Tests & test helpers
packages/core/test/support.ts, packages/core/test/integration/configuration.test.ts, packages/core/test/integration/pool.test.ts, packages/core/test/unit/configuration.test.ts, packages/core/test/integration/sequelize.test.js
Added local DialectName union in tests, adjusted imports/casts and expectations indexing; updated tests to pass dialect classes (or assert class-only behavior) and to use created Sequelize instances in pool tests.
Oracle & lodash ESM updates
packages/oracle/src/_internal/data-types-overrides.ts, packages/oracle/src/query-interface.js
Adjusted Oracle STRING length computation and replaced CommonJS lodash imports with ESM (intersection, uniq).

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant SequelizeCtor as Sequelize.constructor
    participant Internals as sequelize.internals
    participant DialectClass as DialectClass

    rect rgba(200,200,255,0.5)
    User->>SequelizeCtor: new Sequelize({ dialect: "postgres" })  (OLD)
    SequelizeCtor->>Internals: importDialect("postgres")
    Internals->>DialectClass: require dialect package -> return class
    SequelizeCtor->>DialectClass: instantiate dialect class
    end

    rect rgba(200,255,200,0.5)
    User->>SequelizeCtor: new Sequelize({ dialect: PostgresDialectClass })  (NEW)
    SequelizeCtor->>SequelizeCtor: validate typeof dialect === 'function'
    SequelizeCtor->>DialectClass: instantiate dialect class directly
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • sdepold
  • WikiRik

Poem

🐰 I hopped through types and imports bright,
Swapped unions for strings and set classes right.
Validators polished, modules aligned,
Tests now cast where names used to bind.
🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely describes the main change: removing the ability to specify dialect as a string, requiring dialect classes instead.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ephys/drop-require-dialect

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 OpenGrep (1.17.0)
packages/core/test/support.ts

┌──────────────┐
│ Opengrep CLI │
└──────────────┘

�[32m✔�[39m �[1mOpengrep OSS�[0m
�[32m✔�[39m Basic security coverage for first-party code vulnerabilities.

�[1m Loading rules from local config...�[0m


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@ephys
ephys marked this pull request as draft April 6, 2026 20:39
coderabbitai[bot]

This comment was marked as resolved.

@ephys
ephys requested a review from WikiRik April 12, 2026 14:21
@ephys
ephys marked this pull request as ready for review April 12, 2026 14:25
coderabbitai[bot]

This comment was marked as resolved.

@WikiRik WikiRik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assuming tests pass

@WikiRik
WikiRik merged commit 96d74c2 into main Apr 12, 2026
77 checks passed
@WikiRik
WikiRik deleted the ephys/drop-require-dialect branch April 12, 2026 15:28
@github-project-automation github-project-automation Bot moved this from Waiting for merge to To document in PRs & Issues to document on website Apr 12, 2026
papandreou added a commit to papandreou/sequelize that referenced this pull request Apr 15, 2026
* main: (200 commits)
  meta: update actions/upload-artifact action to v7.0.1 (sequelize#18212)
  meta: update sequelize AUTHORS (sequelize#18208)
  feat(cli): add migration generate, run, status & undo (sequelize#18193)
  feat(core): Drop the ability to specify the dialect as a string (sequelize#18204)
  feat: update some dialect adapters (sequelize#18189)
  feat(postgres): replace pg-hstore with inline hstore parser (sequelize#18151)
  feat(core): add `sql.random`, improve `Order` typing (sequelize#18203)
  meta: use Sequelize Bot for drafting PRs (sequelize#18201)
  meta: automatically mark unfinished PRs as draft (sequelize#18197)
  meta: update dependency @oclif/test to v4.1.18 (sequelize#18198)
  fix(core): replace @typeparam with @template in JSDoc (sequelize#18094)
  feat(core): Add support for UUID v7 (sequelize#17832)
  meta: update sequelize AUTHORS (sequelize#18190)
  meta: update dependency @oclif/plugin-help to ^6.2.43 (sequelize#18195)
  meta: update dependency esbuild to v0.28.0 (sequelize#18192)
  meta: update dependency @oclif/plugin-help to ^6.2.42 (sequelize#18191)
  meta: update dependency @oclif/core to ^4.10.5 (sequelize#18187)
  meta: update sequelize AUTHORS (sequelize#18158)
  feat: add Node 24 support, drop Node 18 (sequelize#18185)
  feat(core): add support for readonly attribute arrays (sequelize#18186)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: To document

Development

Successfully merging this pull request may close these issues.

2 participants