Skip to content

Feat: MsSql support#1610

Open
Angelelz wants to merge 67 commits intodrizzle-team:mainfrom
Angelelz:feat-mssql-support
Open

Feat: MsSql support#1610
Angelelz wants to merge 67 commits intodrizzle-team:mainfrom
Angelelz:feat-mssql-support

Conversation

@Angelelz
Copy link
Copy Markdown
Contributor

@Angelelz Angelelz commented Dec 6, 2023

This PR aims to close #585.

The initial implementation and the first couple of tests are implemented. I will update this description with the status of the implementation.
Initially the only supported driver will be node-mssql.
There is still a lot to do:

  • Driver implementation
  • Core functionality
  • Initial basic CRUD API
  • Initial basic CRUD API integration tests
  • Type tests
  • RQB API
  • Merge support (to do upsert type of functionality)
  • schema integration tests
  • custom types integration tests
  • prefixed integration tests
  • Replica tests
  • relational tests
  • Check (and support) most (all?) mssql data types
  • Add support for $onUpdate
  • Others? ⏳

Comment thread integration-tests/tests/mssql.test.ts Fixed
@AndriiSherman
Copy link
Copy Markdown
Member

@Angelelz I guess we should not include RQB in first iteration for MSSQL. So it can be another PR scope, same as Merge support (to do upsert type of functionality)

@Irupt
Copy link
Copy Markdown

Irupt commented Dec 7, 2023

Hello, Thank you for the time you devote to this dialect. I can not wait to see him :)
I looked at some commits, and I wanted to tell you that ntext and text are deprecated and soon deleted: should be replaced by nvarchar(max) varchar(max). These two types are compatible since SQL Server 2012.
Likewise "max" (string) is an acceptable value for "length" of these column types.

@Angelelz
Copy link
Copy Markdown
Contributor Author

Angelelz commented Dec 9, 2023

No idea why the tests are not passing. They run well locally. Any idea @dankochetov ?

@Angelelz Angelelz marked this pull request as ready for review December 12, 2023 02:24
@Angelelz
Copy link
Copy Markdown
Contributor Author

Some features have been postponed to later PRs, the scope of this one is already huge as it is.
Here are some notable ones:

  • Merge clause (to do upserts)
  • Output clause (similar to returning)
  • Select top similar to limit
  • Recursive CTE ergonomics

@AndriiSherman AndriiSherman self-requested a review December 15, 2023 12:19
@AndriiSherman AndriiSherman changed the base branch from main to beta December 15, 2023 12:19
@Angelelz
Copy link
Copy Markdown
Contributor Author

The PR has been updated to resolve conflicts and use the new structures/features of the library.
But there is still some work to do: notably, the new syntax to define columns without the database column name is not implemented. @AndriiSherman Should I implement that feature for this PR or you would prefer to include that feature at a later date?

@Gideon-Felt
Copy link
Copy Markdown

Is no one going to respond to @Angelelz? next steps are needed.

@Aaqu
Copy link
Copy Markdown

Aaqu commented Dec 23, 2024

Is no one going to respond to @Angelelz? next steps are needed.

In my opinion, they are waiting, hoping that a sponsor might come forward. Right now, it’s not profitable for them.

@Angelelz
Copy link
Copy Markdown
Contributor Author

Just to put this out there. This is a 40k+ line PR, and this is only half of what is needed to support mssql. The team will do its best but remember that drizzle-kit support will be needed before this is merged. This PR is only for the ORM side. Mssql requires new syntax to introspect, generate migrations, support the studio, and other drizzle-kit stuff. My understanding is that the team will take care of that part.

@opensas
Copy link
Copy Markdown

opensas commented Dec 23, 2024

Just to put this out there. This is a 40k+ line PR, and this is only half of what is needed to support mssql. The team will do its best but remember that drizzle-kit support will be needed before this is merged. This PR is only for the ORM side. Mssql requires new syntax to introspect, generate migrations, support the studio, and other drizzle-kit stuff. My understanding is that the team will take care of that part.

great, thanks a lot for all this effort

it would be great to have an issue with the remaining tasks, so we can track it, and it would help everybody understand what's still missing

@mfferreira
Copy link
Copy Markdown

Any progress on this?

ProvorovOleksii and others added 6 commits April 16, 2025 13:38
- Added default handling for drizzle-kit
- Changed config type for mssql tables
Removed:
- smalldate and mediumint columns
Added:
- snake_case and camelCase to config
Updated:
- table config and some columns configs. No need to pass names to columns
- View config
Fixed dprint issues
Commented mssql dialect in drizzle-kit
@AleksandrSherman AleksandrSherman changed the base branch from beta to main April 24, 2025 09:20
Updated:
- tests (added names to constraints)
- made constraint names mandatory for mssql
> Mssql generates names with custom hash
- top, offset and fetch are now accept placeholder

Added:
- drizzle mock
- new tests for top, offset and fetch

Also commented mssql logic in drizzle-kit as it is not supported yet
console.log(wrapParam('host', options.host));
console.log(wrapParam('port', options.port, true));
console.log(wrapParam('user', options.user, true));
console.log(wrapParam('password', options.password, true, 'secret'));

Check failure

Code scanning / CodeQL

Clear-text logging of sensitive information High

This logs sensitive data returned by
an access to password
as clear text.

statement += it.generated
? `.generatedAlwaysAs(sql\`${
it.generated.as.replace(

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
statement += `\n\t`;
statement += 'check(';
statement += `"${it.name}", `;
statement += `sql\`${it.value.replace(/`/g, '\\`')}\`)`;

Check failure

Code scanning / CodeQL

Incomplete string escaping or encoding High

This does not escape backslash characters in the input.
@Gideon-Felt
Copy link
Copy Markdown

Gideon-Felt commented May 19, 2025

great, thanks a lot for all this effort

it would be great to have an issue with the remaining tasks, so we can track it, and it would help everybody understand what's still missing

@Angelelz wondering if you saw this? I think they want more visibility on this, I know that would certainly get more eyes on it at least. (and make it easier to delegate remaining work for anyone who want's to also help).

@mfferreira
Copy link
Copy Markdown

Can't wait to use this!

@benalexb
Copy link
Copy Markdown

benalexb commented Aug 6, 2025

Can we please merge this? 🙏🏻 we have all been waiting a long time for this fix. What is blocking it?

@Aaqu
Copy link
Copy Markdown

Aaqu commented Aug 12, 2025

@AndriiSherman any news on mssql? ❤️

@Aaqu
Copy link
Copy Markdown

Aaqu commented Oct 3, 2025

There is a new version of node-mssql 12.0.0, will it be compatible?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEATURE]: MSSQL dialect