MCPcopy Index your code
hub / github.com/brianc/node-postgres / prepare

Method prepare

packages/pg/lib/query.js:209–245  ·  view source on GitHub ↗
(connection)

Source from the content-addressed store, hash-verified

207
208 // http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
209 prepare(connection) {
210 // TODO refactor this poor encapsulation
211 if (!this.hasBeenParsed(connection)) {
212 connection.parse({
213 text: this.text,
214 name: this.name,
215 types: this.types,
216 })
217 }
218
219 // because we're mapping user supplied values to
220 // postgres wire protocol compatible values it could
221 // throw an exception, so try/catch this section
222 try {
223 connection.bind({
224 portal: this.portal,
225 statement: this.name,
226 values: this.values,
227 binary: this.binary,
228 valueMapper: utils.prepareValue,
229 })
230 } catch (err) {
231 // we should close parse to avoid leaking connections
232 connection.close({ type: 'S', name: this.name })
233 connection.sync()
234
235 this.handleError(err, connection)
236 return
237 }
238
239 connection.describe({
240 type: 'P',
241 name: this.portal || '',
242 })
243
244 this._getRows(connection, this.rows)
245 }
246
247 handleCopyInResponse(connection) {
248 connection.sendCopyFail('No source stream defined')

Callers 7

submitMethod · 0.95
index.jsFile · 0.80
domains.jsFile · 0.80
execFunction · 0.80
query-async.jsFile · 0.80
preparedFunction · 0.80
query.jsFile · 0.80

Calls 8

hasBeenParsedMethod · 0.95
handleErrorMethod · 0.95
_getRowsMethod · 0.95
bindMethod · 0.80
syncMethod · 0.80
describeMethod · 0.80
parseMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected