Comparing version 0.5.2 to 0.5.3
@@ -40,3 +40,8 @@ //binary data writer tuned for creating | ||
p.addCString = function(string) { | ||
var string = string || ""; | ||
//just write a 0 for empty or null strings | ||
if(!string) { | ||
this._ensure(1); | ||
this.buffer[this.offset++] = 0; | ||
return this; | ||
} | ||
var len = Buffer.byteLength(string) + 1; | ||
@@ -43,0 +48,0 @@ this._ensure(len); |
{ "name": "pg", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"description": "PostgreSQL client - pure javascript & libpq with the same API", | ||
@@ -4,0 +4,0 @@ "keywords" : ["postgres", "pg", "libpq", "postgre", "database", "rdbms"], |
@@ -69,3 +69,10 @@ require(__dirname + "/test-helper"); | ||
}) | ||
test('writes two empty cstrings', function() { | ||
var subject = new Writer(); | ||
var result = subject.addCString("").addCString("").join(); | ||
assert.equalBuffers(result, [0, 0]) | ||
}) | ||
test('writes non-empty cstring', function() { | ||
@@ -72,0 +79,0 @@ var subject = new Writer(); |
190977
5072