mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
fix gh#36
This commit is contained in:
parent
f395ee646f
commit
1fbe54d5f2
@ -9,6 +9,8 @@ var Query = function(config) {
|
||||
this.rows = config.rows;
|
||||
this.types = config.types;
|
||||
this.name = config.name;
|
||||
//use unique portal name each time
|
||||
this.portal = config.portal || ""
|
||||
this.callback = config.callback;
|
||||
this._fieldNames = [];
|
||||
this._fieldConverters = [];
|
||||
@ -101,7 +103,7 @@ p.hasBeenParsed = function(connection) {
|
||||
|
||||
p.getRows = function(connection) {
|
||||
connection.execute({
|
||||
portal: this.name,
|
||||
portal: this.portalName,
|
||||
rows: this.rows
|
||||
}, true);
|
||||
connection.flush();
|
||||
@ -131,14 +133,14 @@ p.prepare = function(connection) {
|
||||
|
||||
//http://developer.postgresql.org/pgdocs/postgres/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
|
||||
connection.bind({
|
||||
portal: self.name,
|
||||
portal: self.portalName,
|
||||
statement: self.name,
|
||||
values: self.values
|
||||
}, true);
|
||||
|
||||
connection.describe({
|
||||
type: 'P',
|
||||
name: self.name || ""
|
||||
name: self.portalName || ""
|
||||
}, true);
|
||||
|
||||
this.getRows(connection);
|
||||
|
||||
@ -46,3 +46,29 @@ test('a single connection transaction', function() {
|
||||
|
||||
}))
|
||||
})
|
||||
|
||||
test('gh#36', function() {
|
||||
var connectionString = helper.connectionString();
|
||||
helper.pg.connect(connectionString, function(err, client) {
|
||||
if(err) throw err;
|
||||
client.query("BEGIN");
|
||||
client.query({
|
||||
name: 'X',
|
||||
text: "SELECT $1::INTEGER",
|
||||
values: [0]
|
||||
}, assert.calls(function(err, result) {
|
||||
if(err) throw err;
|
||||
assert.equal(result.rows.length, 1);
|
||||
}))
|
||||
client.query({
|
||||
name: 'X',
|
||||
text: "SELECT $1::INTEGER",
|
||||
values: [0]
|
||||
}, assert.calls(function(err, result) {
|
||||
if(err) throw err;
|
||||
assert.equal(result.rows.length, 1);
|
||||
}))
|
||||
client.query("COMMIT")
|
||||
client.on('drain', client.end.bind(client))
|
||||
})
|
||||
})
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user