diff --git a/lib/connection.js b/lib/connection.js index b4198bff..2b5c0139 100644 --- a/lib/connection.js +++ b/lib/connection.js @@ -122,6 +122,7 @@ p.bind = function(config) { config = config || {}; config.portal = config.portal || ''; config.statement = config.statement || ''; + config.binary = config.binary || false; var values = config.values || []; var len = values.length; var buffer = this.writer @@ -139,8 +140,14 @@ p.bind = function(config) { buffer.addString(val); } } - buffer.addInt16(1); // format codes to use binary - buffer.addInt16(1); + + if (config.binary) { + buffer.addInt16(1); // format codes to use binary + buffer.addInt16(1); + } + else { + buffer.addInt16(0); // format codes to use text + } //0x42 = 'B' this._send(0x42, buffer); diff --git a/lib/query.js b/lib/query.js index ecd18858..5747ad32 100644 --- a/lib/query.js +++ b/lib/query.js @@ -10,6 +10,7 @@ var Query = function(config) { this.rows = config.rows; this.types = config.types; this.name = config.name; + this.binary = config.binary; //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; @@ -21,7 +22,7 @@ sys.inherits(Query, EventEmitter); var p = Query.prototype; p.requiresPreparation = function() { - return (this.values || 0).length > 0 || this.name || this.rows; + return (this.values || 0).length > 0 || this.name || this.rows || this.binary; }; @@ -182,7 +183,8 @@ p.prepare = function(connection) { connection.bind({ portal: self.name, statement: self.name, - values: self.values + values: self.values, + binary: self.binary }); connection.describe({