kysely-postgrejs 1.0.1 โ 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -1
- package/README.md +22 -10
- package/package.json +2 -2
- package/postgrejs-dialect-config.d.ts +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
## Changelog
|
|
2
2
|
|
|
3
|
-
### [v1.0
|
|
3
|
+
### [v1.1.0](https://github.com/panates/postgrejs-kysely/compare/v1.0.1...v1.1.0) -
|
|
4
|
+
|
|
5
|
+
#### ๐ Documentation Changes
|
|
6
|
+
|
|
7
|
+
- docs: keep the unspecified parameter types, and say what they cost @Eray Hanoฤlu
|
|
8
|
+
|
|
9
|
+
### [v1.0.1](https://github.com/panates/postgrejs-kysely/compare/v1.0.0...v1.0.1) - 20 September 2026
|
|
4
10
|
|
|
5
11
|
#### ๐ Documentation Changes
|
|
6
12
|
|
package/README.md
CHANGED
|
@@ -62,7 +62,7 @@ The pool you passed in is of course still yours to `acquire()` from directly as
|
|
|
62
62
|
| `pool` | (required) | A PostgreJS `Pool`, or a function returning one. |
|
|
63
63
|
| `fetchAsString` | - | OIDs to hand back as the server's own text. `[DataTypeOIDs.int8]` is how to get `pg`'s bigints. |
|
|
64
64
|
| `fetchCount` | `4294967295` | How many rows a statement may return before the portal suspends. See below. |
|
|
65
|
-
| `inferParameterTypes` | `true` | Whether
|
|
65
|
+
| `inferParameterTypes` | `true` | Whether a `null` parameter is left for PostgreSQL to type from context. |
|
|
66
66
|
| `prepare` | connection's own | Whether statements are cached as server-side prepared statements. `false` for PgBouncer. |
|
|
67
67
|
| `rollbackOnError` | `false` | Whether a failed statement leaves the rest of the transaction usable. See below. |
|
|
68
68
|
| `typeMap` | `GlobalTypeMap` | A custom `DataTypeMap`, to override how individual PostgreSQL types are decoded. |
|
|
@@ -79,19 +79,31 @@ queries; `streamQuery` ignores it and uses Kysely's `chunkSize` as the cursor's
|
|
|
79
79
|
|
|
80
80
|
### Why parameter types are left to the server
|
|
81
81
|
|
|
82
|
-
|
|
83
|
-
|
|
82
|
+
A parameter carrying a declared type is a parameter PostgreSQL will not coerce. Declare a string
|
|
83
|
+
`varchar` and it cannot go into a `json` column; declare a number `int4` and it cannot be coalesced
|
|
84
|
+
with a `varchar` column, compared against `jsonb`, or assigned into one:
|
|
85
|
+
|
|
86
|
+
```
|
|
87
|
+
COALESCE types character varying and integer cannot be matched
|
|
88
|
+
operator does not exist: jsonb = integer
|
|
89
|
+
subscripted assignment to "data" requires type jsonb but expression is of type double precision
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`pg` sends type 0 - unspecified - for everything and lets the server resolve each parameter from
|
|
93
|
+
where it appears, so none of that surfaces there. The dialect does the same for strings, numbers,
|
|
94
|
+
booleans, bigints and nulls. Dates, buffers, arrays and objects keep PostgreJS's typed binary
|
|
95
|
+
encoders, since their text form is not something the server could parse out of context.
|
|
96
|
+
|
|
97
|
+
The cost is a parameter with no context at all: with neither a type nor anything to resolve
|
|
98
|
+
against, PostgreSQL settles on `text`.
|
|
84
99
|
|
|
85
100
|
```ts
|
|
86
|
-
await
|
|
87
|
-
|
|
101
|
+
await sql`select ${5} as v`.execute(db) // '5'
|
|
102
|
+
await sql`select ${5} + 1 as v`.execute(db) // 6 - the context decides
|
|
88
103
|
```
|
|
89
104
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
this surfaces there. The dialect does the same by default. Only strings, numbers, booleans, bigints
|
|
93
|
-
and nulls are affected; dates, buffers, arrays and objects keep PostgreJS's typed, binary encoding,
|
|
94
|
-
which is both correct and faster. Set `inferParameterTypes: false` to declare types again.
|
|
105
|
+
That is the trade, and the three errors above are what the other side of it looks like.
|
|
106
|
+
`inferParameterTypes: false` declares types again.
|
|
95
107
|
|
|
96
108
|
### Getting `pg`'s bigints
|
|
97
109
|
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kysely-postgrejs",
|
|
3
3
|
"description": "Kysely dialect for PostgreJS - run a Kysely query builder on PostgreJS's wire-protocol client",
|
|
4
|
-
"version": "1.0
|
|
4
|
+
"version": "1.1.0",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"peerDependencies": {
|
|
8
8
|
"kysely": ">=0.29.0 <0.31.0",
|
|
9
|
-
"postgrejs": ">=3.
|
|
9
|
+
"postgrejs": ">=3.10.0 <4"
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"module": "./index.js",
|
|
@@ -28,16 +28,16 @@ export interface PostgrejsDialectConfig {
|
|
|
28
28
|
fetchCount?: number;
|
|
29
29
|
/**
|
|
30
30
|
* Whether each parameter's PostgreSQL type is left to the server to
|
|
31
|
-
* resolve from where it appears
|
|
32
|
-
* Kysely's users therefore expect.
|
|
31
|
+
* resolve from where it appears, the way `pg` does.
|
|
33
32
|
*
|
|
34
|
-
* Defaults to `true`.
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
*
|
|
40
|
-
*
|
|
33
|
+
* Defaults to `true`. A declared type is one PostgreSQL will not
|
|
34
|
+
* coerce: a string declared `varchar` cannot go into a `json` column,
|
|
35
|
+
* and a number declared `int4` cannot be coalesced with a `varchar`
|
|
36
|
+
* column, compared against `jsonb`, or assigned into one. Strings,
|
|
37
|
+
* numbers, booleans, bigints and nulls therefore go out unspecified;
|
|
38
|
+
* dates, buffers, arrays and objects keep PostgreJS's typed binary
|
|
39
|
+
* encoding. The cost is that a parameter with no context at all
|
|
40
|
+
* resolves to `text`, so `select $1` with a 5 answers `'5'`.
|
|
41
41
|
*/
|
|
42
42
|
inferParameterTypes?: boolean;
|
|
43
43
|
/**
|