Skip to content

feat: Add CockroachDb support - #15569

Draft
divye11 wants to merge 102 commits into
sequelize:mainfrom
divye11:main
Draft

divye11 wants to merge 102 commits into
sequelize:mainfrom
divye11:main

Conversation

@divye11

@divye11 divye11 commented Jan 17, 2023 •

Copy link
Copy Markdown

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 Change

  • Added dialect support, data types, query generator in order to support cockroachdb natively from sequelize.

Todos

  • CockroachDB transaction isolation works differently, need to find a better way to run tests involving transactions.

@divye11 divye11 changed the title feature: Add CockroachDb support feat: Add CockroachDb support Jan 17, 2023

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

Hello! Thanks for your PR

I know it's a draft but I'm doing a quick preliminary review to put you in the right direction

Don't forget to add cockroachdb to the CI when you're ready :)

constructor() {
super();

this.model.findOrCreate = async options => {

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.

You can't modify a model method dynamically like this. Instead, I recommend modifying findOrCreate and findByPk in model.js to support your use case

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Thanks for the nudge. This has been helpful! I'll make sure to make the changes.

@@ -0,0 +1,7 @@
import * as DataTypes from '../postgres/data-types';

DataTypes.GEOGRAPHY.prototype.getBindParamSql = (value, options): string => {

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.

You can't modify another dialect like this

You should either:

  • make your changes in the postgres data type itself if it's compatible
  • or extend that DataType and replace the method

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Gotcha thanks!

// const __loadDialectModule = super._loadDialectModule;
this._loadDialectModule = (...args) => {
const pg: any = __loadDialectModule(...args);
pg.types.setTypeParser(20, (val: any) => {

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.

Same here you can't make changes that would impact other dialects if yours is running, as users can run multiple instances of Sequelize with different databases

oid 20 is _int8, which should always be returned as a string (for now), not sometimes a string and sometimes a number. We'll eventually change that to use js bigints, but until we do it should remain as a string

Comment thread packages/core/src/sequelize.d.ts Resolved
Comment thread packages/core/.eslintrc.js Resolved
@divye11
divye11 requested review from WikiRik and ephys August 4, 2023 12:05
@divye11
divye11 requested a review from a team as a code owner March 18, 2024 23:04
@sequelize-bot sequelize-bot Bot added the conflicted This PR has merge conflicts and will not be present in the list of PRs to review label Apr 10, 2024
@sequelize-bot

sequelize-bot Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Warning

This pull request has been automatically converted to draft because it is not ready to be merged.

Reason(s):

  • 🔀 Merge conflicts — This PR has merge conflicts that must be resolved before it can be merged.

Once you have addressed the issue(s) above, you may
mark this pull request as ready for review.

@sequelize-bot
sequelize-bot Bot marked this pull request as draft October 26, 2026 00:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

conflicted This PR has merge conflicts and will not be present in the list of PRs to review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants