pg-copy-streams-binary
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -31,2 +31,8 @@ /** | ||
CopyStream.prototype.sendHeader = function(buf) { | ||
buf.put(this.COPYSignature); | ||
buf.word32be(0); // flags field (OID are not included in data) | ||
buf.word32be(0); // Header extention area is empty | ||
} | ||
CopyStream.prototype._transform = function(chunk, enc, cb) { | ||
@@ -40,5 +46,3 @@ | ||
this._headerSent = true; | ||
buf.put(this.COPYSignature); | ||
buf.word32be(0); // flags field (OID are not included in data) | ||
buf.word32be(0); // Header extention area is empty | ||
this.sendHeader(buf); | ||
} | ||
@@ -68,10 +72,19 @@ | ||
var buf = new BufferPut(); | ||
// See [1] - File Header Section | ||
if (!this._headerSent) { | ||
this._headerSent = true; | ||
this.sendHeader(buf); | ||
} | ||
// See [1] - File Trailer section | ||
if (!this._trailerSent) { | ||
this._trailerSent = true; | ||
var trailer = new Buffer([0xff, 0xff]) | ||
this.push(trailer) | ||
buf.put(new Buffer([0xff, 0xff])); | ||
} | ||
this.push(buf.buffer()); | ||
cb(); | ||
} |
{ | ||
"name": "pg-copy-streams-binary", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Streams for parsing and deparsing the COPY binary format", | ||
@@ -31,4 +31,4 @@ "main": "index.js", | ||
"pg": "^6.0.3", | ||
"pg-copy-streams": "^1.1.1" | ||
"pg-copy-streams": "^1.2.0" | ||
} | ||
} |
@@ -13,2 +13,18 @@ var assert = require('assert'); | ||
var testEmpty = function() { | ||
var fromClient = client(); | ||
fromClient.query('CREATE TEMP TABLE plug (col1 text)') | ||
var txt = 'COPY plug FROM STDIN BINARY' | ||
var copyIn = fromClient.query(copy(txt)) | ||
var copyUn = deparser({objectMode: true}); | ||
copyUn.pipe(copyIn); | ||
copyUn.end() | ||
var done = gonna('empty rows should not trigger error'); | ||
copyIn.on('end', function() { | ||
done(); | ||
fromClient.end(); | ||
}) | ||
} | ||
testEmpty(); | ||
var testType = function(type, ndim, value, expectedText) { | ||
@@ -15,0 +31,0 @@ var fromClient = client() |
45718
822