fix gh#36

This commit is contained in:
brianc 2011-07-12 23:08:16 -05:00
parent f395ee646f
commit 1fbe54d5f2
2 changed files with 31 additions and 3 deletions

View File

@ -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);

View File

@ -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))
})
})