Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions .github/workflows/data-table-integration.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
paths:
- '.github/workflows/data-table-integration.yaml'
- 'packages/data-table/**'
- 'packages/data-table-mssql/**'
- 'packages/data-table-postgres/**'
- 'packages/data-table-mysql/**'
- 'packages/data-table-sqlite/**'
Expand All @@ -16,6 +17,7 @@ on:
paths:
- '.github/workflows/data-table-integration.yaml'
- 'packages/data-table/**'
- 'packages/data-table-mssql/**'
- 'packages/data-table-postgres/**'
- 'packages/data-table-mysql/**'
- 'packages/data-table-sqlite/**'
Expand Down Expand Up @@ -54,10 +56,53 @@ jobs:
pnpm --filter @remix-run/data-table-mysql run typecheck
pnpm --filter @remix-run/data-table-mysql run test
pnpm --filter @remix-run/data-table-mysql run build
pnpm --filter @remix-run/data-table-mssql run typecheck
pnpm --filter @remix-run/data-table-mssql run test
pnpm --filter @remix-run/data-table-mssql run build
pnpm --filter @remix-run/data-table-sqlite run typecheck
pnpm --filter @remix-run/data-table-sqlite run test
pnpm --filter @remix-run/data-table-sqlite run build

mssql-integration:
name: MSSQL Integration
runs-on: ubuntu-latest

services:
mssql:
image: mcr.microsoft.com/mssql/server:2022-latest
env:
ACCEPT_EULA: 'Y'
SA_PASSWORD: 'YourStrong!Passw0rd'
ports:
- 1433:1433
options: >-
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P 'YourStrong!Passw0rd' -Q 'SELECT 1' -C"
--health-interval=10s
--health-timeout=5s
--health-retries=20

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Install pnpm
uses: pnpm/action-setup@v4

- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version-file: 'package.json'
cache: pnpm

- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Run mssql integration tests
env:
DATA_TABLE_INTEGRATION: '1'
DATA_TABLE_MSSQL_URL: Server=127.0.0.1,1433;Database=master;User Id=sa;Password=YourStrong!Passw0rd;TrustServerCertificate=true;Encrypt=false
run: pnpm --filter @remix-run/data-table-mssql run test

postgres-integration:
name: Postgres Integration
runs-on: ubuntu-latest
Expand Down
3 changes: 3 additions & 0 deletions packages/data-table-mssql/.changes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Changes Directory

See the [Contributing Guide](../../../CONTRIBUTING.md#adding-a-change-file) for documentation on how to add change files.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Initial release of `@remix-run/data-table-mssql`.
9 changes: 9 additions & 0 deletions packages/data-table-mssql/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# `data-table-mssql` CHANGELOG

This is the changelog for [`data-table-mssql`](https://github.com/remix-run/remix/tree/main/packages/data-table-mssql). It follows [semantic versioning](https://semver.org/).

## v0.1.0

### Minor Changes

- Initial release.
21 changes: 21 additions & 0 deletions packages/data-table-mssql/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Shopify Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
97 changes: 97 additions & 0 deletions packages/data-table-mssql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# data-table-mssql

MSSQL adapter for [`remix/data-table`](https://github.com/remix-run/remix/tree/main/packages/data-table).
Use this package when you want `data-table` APIs backed by `mssql`.

## Features

- **Native `mssql` Integration**: Works with `ConnectionPool`
- **Full `data-table` API Support**: Queries, relations, writes, and transactions
- **MSSQL Capabilities Enabled By Default**:
- `returning: false`
- `savepoints: true`
- `upsert: true`

## Installation

```sh
npm i remix mssql
```

## Usage

```ts
import sql from 'mssql'
import { createDatabase } from 'remix/data-table'
import { createMssqlDatabaseAdapter } from 'remix/data-table-mssql'

let pool = await sql.connect(process.env.DATABASE_URL)

let db = createDatabase(createMssqlDatabaseAdapter(pool))
```

Use `db.query(...)`, relation loading, and transactions from `remix/data-table`.

## Adapter Capabilities

`data-table-mssql` reports this capability set by default:

- `returning: false`
- `savepoints: true`
- `upsert: true`

### `returning` On MSSQL

MSSQL does not support the `RETURNING` clause used by Postgres and SQLite.
When `returning` is `false` (the default), operations like
`db.create(table, values, { returnRow: true })` issue a follow-up `SELECT` to
fetch the created row.

MSSQL _does_ support the `OUTPUT` clause which can serve a similar role. If you
enable the capability override the adapter will use `OUTPUT inserted.*` /
`OUTPUT deleted.*` instead of a follow-up query:

```ts
let adapter = createMssqlDatabaseAdapter(pool, {
capabilities: { returning: true },
})
```

## Advanced Usage

### Transaction Options

Transaction options are passed through to the adapter as hints.

```ts
await db.transaction(async (txDb) => txDb.exec('select 1'), {
isolationLevel: 'serializable',
readOnly: false,
})
```

### Capability Overrides For Testing

You can override capabilities to verify fallback paths in tests.

```ts
import { createMssqlDatabaseAdapter } from 'remix/data-table-mssql'

let adapter = createMssqlDatabaseAdapter(pool, {
capabilities: {
returning: true,
},
})
```

## Related Packages

- [`data-table`](https://github.com/remix-run/remix/tree/main/packages/data-table) - Core query/relations API
- [`data-schema`](https://github.com/remix-run/remix/tree/main/packages/data-schema) - Schema definitions and validation
- [`data-table-postgres`](https://github.com/remix-run/remix/tree/main/packages/data-table-postgres) - Postgres adapter
- [`data-table-mysql`](https://github.com/remix-run/remix/tree/main/packages/data-table-mysql) - MySQL adapter
- [`data-table-sqlite`](https://github.com/remix-run/remix/tree/main/packages/data-table-sqlite) - SQLite adapter

## License

See [LICENSE](https://github.com/remix-run/remix/blob/main/LICENSE)
68 changes: 68 additions & 0 deletions packages/data-table-mssql/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"name": "@remix-run/data-table-mssql",
"version": "0.0.0",
"description": "MSSQL adapter for @remix-run/data-table",
"author": "Michael Jackson <mjijackson@gmail.com>",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/remix-run/remix.git",
"directory": "packages/data-table-mssql"
},
"homepage": "https://github.com/remix-run/remix/tree/main/packages/data-table-mssql#readme",
"files": [
"LICENSE",
"README.md",
"dist",
"src",
"!src/**/*.test.ts"
],
"type": "module",
"sideEffects": false,
"exports": {
".": "./src/index.ts",
"./package.json": "./package.json"
},
"publishConfig": {
"exports": {
".": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"./package.json": "./package.json"
}
},
"devDependencies": {
"@remix-run/data-schema": "workspace:*",
"@remix-run/data-table": "workspace:*",
"@types/mssql": "^9.1.8",
"@types/node": "catalog:",
"@typescript/native-preview": "catalog:",
"mssql": "^12.2.0"
},
"dependencies": {
"@remix-run/data-table": "workspace:^"
},
"peerDependencies": {
"mssql": "^12.2.0"
},
"peerDependenciesMeta": {
"mssql": {
"optional": true
}
},
"scripts": {
"build": "tsgo -p tsconfig.build.json",
"clean": "git clean -fdX",
"prepublishOnly": "pnpm run build",
"test": "node --disable-warning=ExperimentalWarning --test",
"typecheck": "tsgo --noEmit"
},
"keywords": [
"remix",
"orm",
"mssql",
"database",
"sql"
]
}
8 changes: 8 additions & 0 deletions packages/data-table-mssql/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export type {
MssqlDatabaseAdapterOptions,
MssqlDatabasePool,
MssqlDatabaseRequest,
MssqlDatabaseTransaction,
MssqlQueryResult,
} from './lib/adapter.ts'
export { createMssqlDatabaseAdapter, MssqlDatabaseAdapter } from './lib/adapter.ts'
Loading
Loading