Add SQL Server Support & Drizzle ORM 1.0 Beta Compatibility#24
Open
ianfrye0818 wants to merge 6 commits intodrizzle-team:mainfrom
Open
Add SQL Server Support & Drizzle ORM 1.0 Beta Compatibility#24ianfrye0818 wants to merge 6 commits intodrizzle-team:mainfrom
ianfrye0818 wants to merge 6 commits intodrizzle-team:mainfrom
Conversation
- Add complete MSSQL generator with type mappings - Update provider detection to support sqlserver - Refactor all generators for consistency
- Change condition from `if (field.default)` to `if (field.hasDefaultValue)` - Fixes bug where default values of 0, false, or "" were ignored - Applies to all generators: pg, mysql, sqlite, mssql
- Migrate from individual relation exports to single defineRelations - Update relation syntax to r.one.Model() and r.many.Model() - Change rqb data structure to Record<string, string[]> - Add tablesWithRelations Set for tracking
- Add test suites for all 4 database generators - Set up Vitest with @vitest/ui - 100% test pass rate across pg, mysql, sqlite, mssql - Add test fixtures and helper functions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces breaking changes to support Drizzle ORM 1.0.0-beta.1's new
defineRelationsAPI.Summary
This PR adds SQL Server (MSSQL) support to the generator and updates all database generators (PostgreSQL, MySQL, SQLite, MSSQL) to be compatible with Drizzle ORM's 1.0 beta release, which introduces the new
defineRelationsAPI. Additionally, it includes a comprehensive test suite and critical bug fixes.Key Changes
New Features
src/util/generators/mssql.ts)varchar,nvarchar,int,bigint,datetime,uniqueidentifier, etc.sqlserverBreaking Changes
relationsexports to singledefineRelationsexportone(Model, {...})tor.one.Model({...})rqb: string[]torqb: Record<string, string[]>tablesWithRelationsSet to track which tables have relationsexport const relations = defineRelations({ ...tables }, (r) => ({...}))Bug Fixes
if (field.default)toif (field.hasDefaultValue && field.default !== undefined)0,false, and""Testing
@vitest/uifor interactive testingpnpm test,pnpm test:watch,pnpm test:uiDocumentation
Files Changed
New Files:
src/util/generators/mssql.ts- SQL Server generatorsrc/util/generators/__tests__/*.test.ts- Test suites for all 4 generatorssrc/util/generators/__tests__/test-fixtures.ts- Shared test fixturesvitest.config.ts- Vitest configurationTEST_SUMMARY.md- Test documentationModified Files:
src/util/generators/pg.ts- Updated for defineRelations + bug fixessrc/util/generators/mysql.ts- Updated for defineRelations + bug fixessrc/util/generators/sqlite.ts- Updated for defineRelations + bug fixessrc/index.ts- Added MSSQL provider supportsrc/util/extract-many-to-many-models/index.ts- Code improvementsREADME.md- Updated documentationTest Results
✓ src/util/generators/tests/mssql.test.ts (27 tests)
✓ src/util/generators/tests/mysql.test.ts (30 tests)
✓ src/util/generators/tests/pg.test.ts (33 tests)
✓ src/util/generators/tests/sqlite.test.ts (28 tests)
Test Files 4 passed (4)
Tests 118 passed (118)
Migration Guide
For users upgrading to this version:
defineRelationsinstead of individual relation exportsrelationsexportBefore:
After:
Breaking Changes
Supported Databases
Stats: 18 files changed, 7302 insertions(+), 952 deletions(-)