Skip to content

Commit 1b4518f

Browse files
author
alxndrsn
committed
maybe?
1 parent 0096856 commit 1b4518f

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

docs/pages/apis/client.mdx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ type QueryConfig {
7575

7676
// custom type parsers just for this query result
7777
types?: Types;
78+
79+
// force extended query usage - prevents multiple statements in a
80+
// single query
81+
forcePreparation?: boolean;
7882
}
7983
```
8084

packages/pg/lib/native/query.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var NativeQuery = (module.exports = function (config, values, callback) {
1010
this.text = config.text
1111
this.values = config.values
1212
this.name = config.name
13+
this.forcePreparation = config.forcePreparation
1314
this.callback = config.callback
1415
this.state = 'new'
1516
this._arrayMode = config.rowMode === 'array'
@@ -159,6 +160,8 @@ NativeQuery.prototype.submit = function (client) {
159160
}
160161
var vals = this.values.map(utils.prepareValue)
161162
client.native.query(this.text, vals, after)
163+
} else if (this.forcePreparation) {
164+
client.native.query(this.text, [], after)
162165
} else {
163166
client.native.query(this.text, after)
164167
}

packages/pg/lib/query.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ class Query extends EventEmitter {
1616
this.rows = config.rows
1717
this.types = config.types
1818
this.name = config.name
19+
this.forcePreparation = config.forcePreparation
1920
this.binary = config.binary
2021
// use unique portal name each time
2122
this.portal = config.portal || ''
@@ -32,6 +33,11 @@ class Query extends EventEmitter {
3233
}
3334

3435
requiresPreparation() {
36+
// preparation has been requested
37+
if (this.forcePreparation) {
38+
return true
39+
}
40+
3541
// named queries must always be prepared
3642
if (this.name) {
3743
return true

0 commit comments

Comments
 (0)