Skip to content

Commit de9d5e3

Browse files
author
Sandro Santilli
committed
Cleanly handle missing stream error on COPY operation. Closes brianc#241
1 parent 21c31f6 commit de9d5e3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/query.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,9 +170,11 @@ p.prepare = function(connection) {
170170
this.getRows(connection);
171171
};
172172
p.streamData = function (connection) {
173-
this.stream.startStreamingToConnection(connection);
173+
if ( this.stream ) this.stream.startStreamingToConnection(connection);
174+
else this.handleError(new Error('No destination stream defined'));
174175
};
175176
p.handleCopyFromChunk = function (chunk) {
176-
this.stream.handleChunk(chunk);
177+
if ( this.stream ) this.stream.handleChunk(chunk);
178+
else this.handleError(new Error('error', 'No source stream defined'));
177179
}
178180
module.exports = Query;

0 commit comments

Comments
 (0)