Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: depot/kysely-planetscale
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.2.0
Choose a base ref
...
head repository: depot/kysely-planetscale
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref
Loading
Showing with 1,238 additions and 701 deletions.
  1. +4 −6 .github/workflows/ci.yml
  2. +0 −8 .prettierrc.cjs
  3. +1 −1 .vscode/settings.json
  4. +1 −1 LICENSE
  5. +19 −1 README.md
  6. +31 −13 package.json
  7. +1,131 −648 pnpm-lock.yaml
  8. +50 −22 src/index.ts
  9. +1 −1 tsconfig.json
10 changes: 4 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -6,15 +6,13 @@ jobs:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: pnpm/action-setup@v2
with:
version: 7.x.x
- uses: pnpm/action-setup@v4

- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: '16'
node-version: '18'
cache: pnpm

- run: pnpm install --frozen-lockfile
8 changes: 0 additions & 8 deletions .prettierrc.cjs

This file was deleted.

2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"prettier.prettierPath": "node_modules/prettier/index.js",
"prettier.prettierPath": "node_modules/prettier/index.cjs",
"typescript.tsdk": "node_modules/typescript/lib",
"typescript.enablePromptUseWorkspaceTsdk": true
}
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2022 Jacob Gillespie <jacobwgillespie@gmail.com>
Copyright (c) 2022-2024 Jacob Gillespie <jacobwgillespie@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -62,7 +62,7 @@ const db = new Kysely<Database>({

#### Custom `format` function

`PlanetScaleDialect` passes all parameters to `@planetscale/database` unmodified, expect for JavaScript Dates, which are converted to MySQL strings. If you [set a `format` function](https://github.com/planetscale/database-js#custom-query-parameter-format-function), you can override this behavior:
`PlanetScaleDialect` passes all parameters to `@planetscale/database` unmodified, except for JavaScript Dates, which are converted to MySQL strings. If you [set a `format` function](https://github.com/planetscale/database-js#custom-query-parameter-format-function), you can override this behavior:

```typescript
import {Kysely} from 'kysely'
@@ -102,6 +102,24 @@ function inflate(field, value) {
}
```

#### Experimental: `useSharedConnection`

As of version 1.3.0, `PlanetScaleDialect` supports using a shared `@planetscale/database` connection for all non-transaction queries, to improve query performance. This option is not enabled by default, but can be enabled by setting the `useSharedConnection` option to `true`. Transaction queries will always run using their own connection.

This is an experimental feature, and may be removed in a future version.

```typescript
import {Kysely} from 'kysely'
import {PlanetScaleDialect} from 'kysely-planetscale'

const db = new Kysely<Database>({
dialect: new PlanetScaleDialect({
url: process.env.DATABASE_URL,
useSharedConnection: true,
}),
})
```

## License

MIT License, see `LICENSE`.
44 changes: 31 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
{
"name": "kysely-planetscale",
"version": "1.2.0",
"version": "1.5.0",
"type": "module",
"description": "Kysely dialect for PlanetScale Serverless",
"repository": "https://github.com/depot/kysely-planetscale.git",
"homepage": "https://github.com/depot/kysely-planetscale",
"author": "Jacob Gillespie <jacobwgillespie@gmail.com>",
"license": "MIT",
"packageManager": "pnpm@9.7.1",
"main": "./dist/index.js",
"module": "./dist/index.js",
"exports": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"require": "./dist/index.cjs"
},
"types": "./dist/index.d.ts",
"files": [
"dist"
@@ -20,7 +27,7 @@
"serverless"
],
"scripts": {
"build": "tsup src/index.ts --format esm --dts --clean",
"build": "tsup src/index.ts --format esm,cjs --dts --clean",
"clean": "rm -rf dist",
"fmt": "prettier --write .",
"fmt:check": "prettier --check .",
@@ -32,18 +39,29 @@
"kysely": "*"
},
"dependencies": {
"date-fns": "^2.29.3"
"date-fns": "^3.6.0"
},
"devDependencies": {
"@planetscale/database": "^1.3.0",
"@tsconfig/node14": "^1.0.3",
"@types/node": "^18.7.20",
"kysely": "^0.21.6",
"prettier": "^2.7.1",
"prettier-plugin-organize-imports": "^3.1.1",
"prettier-plugin-pkg": "^0.17.1",
"tsup": "^6.2.3",
"typescript": "^4.8.3"
"@planetscale/database": "^1.19.0",
"@tsconfig/node18": "^18.2.4",
"@types/node": "^20.4.5",
"kysely": "^0.27.4",
"prettier": "^3.3.3",
"prettier-plugin-organize-imports": "^4.0.0",
"prettier-plugin-pkg": "^0.18.1",
"tsup": "^8.2.4",
"typescript": "^5.5.4"
},
"sideEffects": false
"sideEffects": false,
"prettier": {
"printWidth": 120,
"semi": false,
"singleQuote": true,
"trailingComma": "all",
"bracketSpacing": false,
"plugins": [
"prettier-plugin-organize-imports",
"prettier-plugin-pkg"
]
}
}
Loading