mirror of
https://github.com/brianc/node-postgres.git
synced 2026-01-18 15:55:05 +00:00
initial work on binding
This commit is contained in:
parent
95ec1b403c
commit
5650b02993
@ -129,6 +129,24 @@ p.parse = function(query) {
|
||||
return this;
|
||||
};
|
||||
|
||||
p.bind = function(config) {
|
||||
//normalize config
|
||||
config = config || {};
|
||||
config.portalName = config.portalName || '';
|
||||
config.statementName = config.statementName || '';
|
||||
config.values = config.values || [];
|
||||
var buffer = new BufferList()
|
||||
.addCString(config.portalName)
|
||||
.addCString(config.statementName)
|
||||
.addInt16(0) //always use default text format
|
||||
.addInt16(0); //number of parameters
|
||||
if(config.values.length > 0) {
|
||||
sys.debug("Not supporting parameters yet");
|
||||
}
|
||||
buffer.addInt16(0); //no format codes, use text
|
||||
this.send('B', buffer.join());
|
||||
};
|
||||
|
||||
p.pulseQueryQueue = function(ready) {
|
||||
if(!this.readyForQuery) {
|
||||
return;
|
||||
|
||||
@ -10,6 +10,7 @@ var readyForQueryBuffer = buffers.readyForQuery();
|
||||
var backendKeyDataBuffer = buffers.backendKeyData(1,2);
|
||||
var commandCompleteBuffer = buffers.commandComplete("SELECT 3");
|
||||
|
||||
|
||||
var addRow = function(bufferList, name, offset) {
|
||||
return bufferList.addCString(name) //field name
|
||||
.addInt32(offset++) //table id
|
||||
|
||||
@ -40,7 +40,21 @@ test('prepared queries', function() {
|
||||
//server raises parse complete message
|
||||
|
||||
test('sends bind message', function() {
|
||||
return false;
|
||||
|
||||
test('binding to unnamed prepared statement with no values', function() {
|
||||
|
||||
client.bind();
|
||||
assert.length(client.stream.packets, 1);
|
||||
var packet = client.stream.packets.pop();
|
||||
var expectedBuffer = new BufferList()
|
||||
.addCString("")
|
||||
.addCString("")
|
||||
.addInt16(0)
|
||||
.addInt16(0)
|
||||
.addInt16(0).join(true,"B");
|
||||
assert.equalBuffers(packet, expectedBuffer);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
test('recieves rows', function() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user