Skip to content

feat(core): Add support for UUID v7 - #17832

Merged
ephys merged 3 commits into
sequelize:mainfrom
ihmpavel:feat-uuid-v7
Apr 5, 2026
Merged

ephys merged 3 commits into
sequelize:mainfrom
ihmpavel:feat-uuid-v7

Conversation

@ihmpavel

@ihmpavel ihmpavel commented Apr 14, 2025 •

Copy link
Copy Markdown
Contributor

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

Add support for UUID v7

List of Breaking Changes

Summary by CodeRabbit

Release Notes

  • New Features

    • Added UUID version 7 support for generating and validating UUID v7 values
    • New sql.uuidV7 expression builder for use as default values in models
    • UUID v7 accessor on the UUID data type for explicit version specification
  • Tests

    • Extended test coverage for UUID v7 generation and validation

@ihmpavel
ihmpavel requested a review from a team as a code owner April 14, 2025 14:56
@ihmpavel
ihmpavel requested review from ephys and sdepold April 14, 2025 14:56
@ihmpavel
ihmpavel force-pushed the feat-uuid-v7 branch 2 times, most recently from 13ce2dc to e329ddf Compare April 14, 2025 14:58
@WikiRik

WikiRik commented Apr 14, 2025

Copy link
Copy Markdown
Member

Thanks for working on this! I quickly scanned through it and I noticed that we're also adding support in the deprecated DataTypes definition. I would prefer if we didn't add deprecated functionality

Copilot AI review requested due to automatic review settings April 5, 2026 12:26
@coderabbitai

coderabbitai Bot commented Apr 5, 2026 •

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Added UUID v7 support to the framework, extending the UUID type and dialect infrastructure to support version 7 generation alongside v1 and v4, including new type accessors, dialect capability flags, query generator methods, expression builders, and comprehensive test coverage.

Changes

Cohort / File(s) Summary
Core Type System
packages/core/src/abstract-dialect/data-types.ts, packages/core/src/abstract-dialect/dialect.ts
Extended UuidOptions.version to include 7, added V7 instance and static getters to UUID class, and introduced uuidV7Generation dialect support flag (defaults to false).
Query Generation
packages/core/src/abstract-dialect/query-generator-typescript.ts, packages/core/src/expression-builders/uuid.ts, packages/core/src/expression-builders/sql.ts
Added getUuidV7FunctionCall() method to query generator, created new SqlUuidV7 class extending DialectAwareFn with v7 JavaScript/dialect-specific generation, and exposed sql.uuidV7 builder; also updated SqlUuidV4 to use uuid package v4 generator.
Utilities
packages/core/src/utils/deprecations.ts, packages/core/src/utils/dialect.ts
Updated deprecation message to include sql.uuidV7 as an allowed replacement; refactored UUID v4 default value generation to use uuid package instead of Node crypto.
Integration Tests
packages/core/test/integration/instance.test.js, packages/core/test/integration/instance/update.test.js, packages/core/test/smoke/smoketests.test.js
Added uuidv7 column definitions to test models; extended default-value and multi-primary-key test assertions to verify v7 generation and validation.
Unit Tests
packages/core/test/unit/data-types/uuid.test.ts
Extended UUID validation unit tests to include v7 generator import, DataTypes.UUID.V7 reference, and cross-version validation assertions (v7 rejects v1 values, v4 rejects v7 values, etc.).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • sdepold
  • WikiRik

Poem

🐰 A seventh version hops into view,
UUID V7 joins the squad so true,
With getters, flags, and builders bright,
Sequelize now generates versions right,
From JavaScript to dialects wide,
UUID V7 takes its hop with pride! 🥕✨

🚥 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 clearly and concisely summarizes the main change: adding UUID v7 support to the core codebase, which is reflected across all modified files.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.16.5)
packages/core/src/abstract-dialect/query-generator-typescript.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

packages/core/src/abstract-dialect/dialect.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

packages/core/src/abstract-dialect/data-types.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

  • 8 others

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 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.

This looks good to me. If the CI passes, it can be merged. Thank you for your work

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds UUID v7 support to Sequelize Core by introducing a new UUID version option (DataTypes.UUID.V7) and a corresponding default-value generator (sql.uuidV7), plus plumbing for future dialect-native UUID v7 generation.

Changes:

  • Add DataTypes.UUID.V7 and extend UUID validation options to include version 7.
  • Add sql.uuidV7 (DialectAwareFn) and a new uuidV7Generation dialect support flag + abstract query-generator hook.
  • Update unit/integration/smoke tests to exercise UUID v7 defaults and validation.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated no comments.

Show a summary per file
File Description
packages/core/test/unit/data-types/uuid.test.ts Adds UUID v7 validation tests for DataTypes.UUID.V7.
packages/core/test/smoke/smoketests.test.js Adds a uuidv7 model attribute using sql.uuidV7.
packages/core/test/integration/instance/update.test.js Adds uuidv7 defaultValue coverage in update integration tests.
packages/core/test/integration/instance.test.js Extends default UUID assertions to include v7 and adds v7 to composite PK test.
packages/core/src/utils/dialect.ts Switches deprecated UUIDV4 default generation to uuid.v4() and adds uuidv4 import.
packages/core/src/utils/deprecations.ts Updates deprecation message to mention sql.uuidV7.
packages/core/src/expression-builders/uuid.ts Introduces SqlUuidV7 and switches v4 JS generation to uuid.v4().
packages/core/src/expression-builders/sql.ts Exposes sql.uuidV7.
packages/core/src/abstract-dialect/query-generator-typescript.ts Adds getUuidV7FunctionCall() abstract hook with support-flag guard.
packages/core/src/abstract-dialect/dialect.ts Adds uuidV7Generation to dialect support flags (default false).
packages/core/src/abstract-dialect/data-types.ts Adds UUID option/version support for v7 + UUID.V7 getter/static.
Comments suppressed due to low confidence (1)

packages/core/src/abstract-dialect/data-types.ts:1975

  • The UUID data type JSDoc still says to use only sql.uuidV1 or sql.uuidV4 for default values, but this PR adds sql.uuidV7 as well. Update this documentation (and ideally the example) so users discover UUID v7 support via the public docs/comments.
/**
 * A column storing a unique universal identifier.
 * Use with `sql.uuidV1` or `sql.uuidV4` for default values.
 *

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
packages/core/src/abstract-dialect/data-types.ts (1)

1972-1975: Update docstring to mention UUID v7.

The class documentation mentions sql.uuidV1 and sql.uuidV4 but should also reference sql.uuidV7 now that v7 support has been added.

📝 Suggested docstring update
 /**
  * A column storing a unique universal identifier.
- * Use with `sql.uuidV1` or `sql.uuidV4` for default values.
+ * Use with `sql.uuidV1`, `sql.uuidV4`, or `sql.uuidV7` for default values.
  *
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@packages/core/src/abstract-dialect/data-types.ts` around lines 1972 - 1975,
Update the UUID column docstring (the comment above the UUID column/data type
class in packages/core/src/abstract-dialect/data-types.ts) to include sql.uuidV7
alongside the existing references to sql.uuidV1 and sql.uuidV4; specifically,
mention that the column can be used with sql.uuidV1, sql.uuidV4, or sql.uuidV7
for default values so users know v7 is supported.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In `@packages/core/src/abstract-dialect/data-types.ts`:
- Around line 1972-1975: Update the UUID column docstring (the comment above the
UUID column/data type class in packages/core/src/abstract-dialect/data-types.ts)
to include sql.uuidV7 alongside the existing references to sql.uuidV1 and
sql.uuidV4; specifically, mention that the column can be used with sql.uuidV1,
sql.uuidV4, or sql.uuidV7 for default values so users know v7 is supported.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 550dc96b-8f80-40bb-a2b8-155fb23f7ef8

📥 Commits

Reviewing files that changed from the base of the PR and between 320e7f2 and 9f44695.

📒 Files selected for processing (11)
  • packages/core/src/abstract-dialect/data-types.ts
  • packages/core/src/abstract-dialect/dialect.ts
  • packages/core/src/abstract-dialect/query-generator-typescript.ts
  • packages/core/src/expression-builders/sql.ts
  • packages/core/src/expression-builders/uuid.ts
  • packages/core/src/utils/deprecations.ts
  • packages/core/src/utils/dialect.ts
  • packages/core/test/integration/instance.test.js
  • packages/core/test/integration/instance/update.test.js
  • packages/core/test/smoke/smoketests.test.js
  • packages/core/test/unit/data-types/uuid.test.ts

@ephys
ephys merged commit 5ed1d10 into sequelize:main Apr 5, 2026
78 checks passed
@github-project-automation github-project-automation Bot moved this from Waiting for merge to To document in PRs & Issues to document on website Apr 5, 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)
  ...
@WikiRik WikiRik mentioned this pull request Jul 13, 2026
4 of 8 tasks
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.

4 participants