Use strict
This commit is contained in:
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
module.exports = function(txt, options) {
|
module.exports = function(txt, options) {
|
||||||
return new CopyStreamQuery(txt, options)
|
return new CopyStreamQuery(txt, options)
|
||||||
}
|
}
|
||||||
@@ -77,7 +79,7 @@ CopyStreamQuery.prototype._transform = function(chunk, enc, cb) {
|
|||||||
case code.NoticeResponse:
|
case code.NoticeResponse:
|
||||||
case code.NotificationResponse:
|
case code.NotificationResponse:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case code.ErrorResponse:
|
case code.ErrorResponse:
|
||||||
case code.CopyDone:
|
case code.CopyDone:
|
||||||
this.pushBufferIfneeded();
|
this.pushBufferIfneeded();
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var CopyToQueryStream = require('./copy-to')
|
var CopyToQueryStream = require('./copy-to')
|
||||||
module.exports = {
|
module.exports = {
|
||||||
to: function(txt, options) {
|
to: function(txt, options) {
|
||||||
|
|||||||
+4
-2
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var gonna = require('gonna')
|
var gonna = require('gonna')
|
||||||
|
|
||||||
@@ -19,7 +21,7 @@ var testBinaryCopy = function() {
|
|||||||
var fromClient = client()
|
var fromClient = client()
|
||||||
var toClient = client()
|
var toClient = client()
|
||||||
|
|
||||||
queries = [
|
var queries = [
|
||||||
'DROP TABLE IF EXISTS data',
|
'DROP TABLE IF EXISTS data',
|
||||||
'CREATE TABLE IF NOT EXISTS data (num BIGINT, word TEXT)',
|
'CREATE TABLE IF NOT EXISTS data (num BIGINT, word TEXT)',
|
||||||
'INSERT INTO data (num, word) VALUES (1, \'hello\'), (2, \'other thing\'), (3, \'goodbye\')',
|
'INSERT INTO data (num, word) VALUES (1, \'hello\'), (2, \'other thing\'), (3, \'goodbye\')',
|
||||||
@@ -33,7 +35,7 @@ var testBinaryCopy = function() {
|
|||||||
var fromStream = fromClient.query(to('COPY (SELECT * FROM data) TO STDOUT BINARY'))
|
var fromStream = fromClient.query(to('COPY (SELECT * FROM data) TO STDOUT BINARY'))
|
||||||
var toStream = toClient.query(from('COPY data_copy FROM STDIN BINARY'))
|
var toStream = toClient.query(from('COPY data_copy FROM STDIN BINARY'))
|
||||||
|
|
||||||
runStream = function(callback) {
|
var runStream = function(callback) {
|
||||||
fromStream.on('error', callback)
|
fromStream.on('error', callback)
|
||||||
toStream.on('error', callback)
|
toStream.on('error', callback)
|
||||||
toStream.on('finish', callback)
|
toStream.on('finish', callback)
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var gonna = require('gonna')
|
var gonna = require('gonna')
|
||||||
|
|
||||||
@@ -68,6 +70,6 @@ var testSingleEnd = function() {
|
|||||||
if (count == 1) fromClient.end();
|
if (count == 1) fromClient.end();
|
||||||
})
|
})
|
||||||
stream.end(Buffer('1\n'))
|
stream.end(Buffer('1\n'))
|
||||||
|
|
||||||
}
|
}
|
||||||
testSingleEnd()
|
testSingleEnd()
|
||||||
|
|||||||
+5
-5
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
var assert = require('assert')
|
var assert = require('assert')
|
||||||
var gonna = require('gonna')
|
var gonna = require('gonna')
|
||||||
|
|
||||||
@@ -29,7 +31,7 @@ var testComparators = function() {
|
|||||||
assert(copy1._gotCopyOutResponse, 'should have received CopyOutResponse')
|
assert(copy1._gotCopyOutResponse, 'should have received CopyOutResponse')
|
||||||
assert(!copy1._remainder, 'Message with no additional data (len=Int4Len+0) should not leave a remainder')
|
assert(!copy1._remainder, 'Message with no additional data (len=Int4Len+0) should not leave a remainder')
|
||||||
}))
|
}))
|
||||||
copy1.end(new Buffer([code.CopyOutResponse, 0x00, 0x00, 0x00, 0x04]));
|
copy1.end(new Buffer([code.CopyOutResponse, 0x00, 0x00, 0x00, 0x04]));
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -104,8 +106,8 @@ var testNoticeResponse = function() {
|
|||||||
stream.on('data', function(data) {
|
stream.on('data', function(data) {
|
||||||
})
|
})
|
||||||
stream.on('error', callback)
|
stream.on('error', callback)
|
||||||
|
|
||||||
// make sure stream is pulled from
|
// make sure stream is pulled from
|
||||||
stream.pipe(concat(callback.bind(null,null)))
|
stream.pipe(concat(callback.bind(null,null)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,5 +120,3 @@ var testNoticeResponse = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
testNoticeResponse();
|
testNoticeResponse();
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
require('./copy-from')
|
require('./copy-from')
|
||||||
require('./copy-to')
|
require('./copy-to')
|
||||||
require('./binary')
|
require('./binary')
|
||||||
|
|||||||
Reference in New Issue
Block a user