diff --git a/lib/query.js b/lib/query.js index a3330231..1185a2ad 100644 --- a/lib/query.js +++ b/lib/query.js @@ -170,9 +170,11 @@ p.prepare = function(connection) { this.getRows(connection); }; p.streamData = function (connection) { - this.stream.startStreamingToConnection(connection); + if ( this.stream ) this.stream.startStreamingToConnection(connection); + else this.handleError(new Error('No destination stream defined')); }; p.handleCopyFromChunk = function (chunk) { - this.stream.handleChunk(chunk); + if ( this.stream ) this.stream.handleChunk(chunk); + else this.handleError(new Error('error', 'No source stream defined')); } module.exports = Query;