(connection)
| 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') |
no test coverage detected