mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
start chopping up client to support prepared statements
This commit is contained in:
parent
2c6f85beb9
commit
adc8bfa7bf
@ -76,7 +76,8 @@ p.pulseQueryQueue = function() {
|
||||
};
|
||||
|
||||
p.query = function(config) {
|
||||
var query = new Query({text: config});
|
||||
//can take in strings or config objects
|
||||
var query = new Query(config.text ? config : { text: config });
|
||||
this.queryQueue.push(query);
|
||||
this.pulseQueryQueue();
|
||||
return query;
|
||||
@ -92,17 +93,29 @@ Client.md5 = function(string) {
|
||||
|
||||
var Query = function(config) {
|
||||
this.text = config.text;
|
||||
this.values = config.values;
|
||||
this.rows = config.rows;
|
||||
this.types = config.types;
|
||||
this.name = config.name;
|
||||
//for code clarity purposes we'll declare this here though it's not
|
||||
//set or used until a rowDescription message comes in
|
||||
this.rowDescription = null;
|
||||
EventEmitter.call(this);
|
||||
};
|
||||
sys.inherits(Query, EventEmitter);p
|
||||
sys.inherits(Query, EventEmitter);
|
||||
var p = Query.prototype;
|
||||
|
||||
p.isBoundCommand = function() {
|
||||
return (this.values || 0).length > 0 || this.name || this.rows;
|
||||
};
|
||||
|
||||
p.submit = function(connection) {
|
||||
var self = this;
|
||||
connection.query(this.text);
|
||||
if(this.isBoundCommand()) {
|
||||
throw new Error('Bound command not supported yet! :(');
|
||||
} else {
|
||||
connection.query(this.text);
|
||||
}
|
||||
var handleRowDescription = function(msg) {
|
||||
self.onRowDescription(msg);
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user