Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e0aa7db324 | ||
|
|
0f0ddf7ad4 |
10
index.js
10
index.js
@@ -39,7 +39,6 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
|
||||
lenBuffer.writeUInt32BE(chunk.length + 4, 0)
|
||||
this.push(lenBuffer)
|
||||
this.push(chunk)
|
||||
this.rowCount++
|
||||
cb()
|
||||
}
|
||||
|
||||
@@ -58,7 +57,14 @@ CopyStreamQuery.prototype.handleCopyInResponse = function(connection) {
|
||||
this.pipe(connection.stream)
|
||||
}
|
||||
|
||||
CopyStreamQuery.prototype.handleCommandComplete = function() {
|
||||
CopyStreamQuery.prototype.handleCommandComplete = function(msg) {
|
||||
// Parse affected row count as in
|
||||
// https://github.com/brianc/node-postgres/blob/35e5567f86774f808c2a8518dd312b8aa3586693/lib/result.js#L37
|
||||
var match = /COPY (\d+)/.exec((msg || {}).text)
|
||||
if (match) {
|
||||
this.rowCount = parseInt(match[1], 10)
|
||||
}
|
||||
|
||||
this.unpipe()
|
||||
this.emit('end')
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "pg-copy-streams",
|
||||
"version": "1.0.0",
|
||||
"version": "1.1.0",
|
||||
"description": "Low-Level COPY TO and COPY FROM streams for PostgreSQL in JavaScript using",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
@@ -30,10 +30,6 @@ var testRange = function(top) {
|
||||
|
||||
var txt = 'COPY numbers FROM STDIN'
|
||||
var stream = fromClient.query(copy(txt))
|
||||
var rowEmitCount = 0
|
||||
stream.on('row', function() {
|
||||
rowEmitCount++
|
||||
})
|
||||
for(var i = 0; i < top; i++) {
|
||||
stream.write(Buffer('' + i + '\t' + i*10 + '\n'))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user