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 CHANGED
@@ -1,6 +1,12 @@
1
1
  ## Changelog
2
2
 
3
- ### [v1.0.1](https://github.com/panates/postgrejs-kysely/compare/v1.0.0...v1.0.1) -
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 PostgreSQL resolves each parameter's type from context, as it does for `pg`. |
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
- PostgreJS gives every parameter a type OID taken from its JavaScript value, so a string arrives
83
- declared as `varchar`. That is a declaration, not a hint, and PostgreSQL stops inferring:
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 db.insertInto('log').values({ payload: '{"a":1}' }).execute()
87
- // column "payload" is of type json but expression is of type character varying
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
- `coalesce($1, 1)`, `$1 || name` and any call to an overloaded function fail the same way. `pg` sends
91
- type 0 - unspecified - and lets PostgreSQL resolve each parameter from where it appears, so none of
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.1",
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.7.0 <4"
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 in the query - what `pg` does, and what
32
- * Kysely's users therefore expect.
31
+ * resolve from where it appears, the way `pg` does.
33
32
  *
34
- * Defaults to `true`. PostgreJS otherwise declares a type derived from
35
- * the JavaScript value, which makes a string a `varchar` and breaks
36
- * every context where PostgreSQL would have inferred something else: a
37
- * `json` column, a `coalesce` of mixed types, `||`, an overloaded
38
- * function. Only strings, numbers, booleans, bigints and nulls are
39
- * affected - dates, buffers, arrays and objects keep PostgreJS's typed,
40
- * binary encoding either way.
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
  /**