Skip to content

Commit c2f4b28

Browse files
authored
Implement handleEmptyQuery for pg-query-stream. (brianc#2106)
1 parent 8231531 commit c2f4b28

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

packages/pg-query-stream/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class PgQueryStream extends Readable {
1515
this.handleCommandComplete = this.cursor.handleCommandComplete.bind(this.cursor)
1616
this.handleReadyForQuery = this.cursor.handleReadyForQuery.bind(this.cursor)
1717
this.handleError = this.cursor.handleError.bind(this.cursor)
18+
this.handleEmptyQuery = this.cursor.handleEmptyQuery.bind(this.cursor)
1819
}
1920

2021
submit(connection) {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const assert = require('assert')
2+
const helper = require('./helper')
3+
const QueryStream = require('../')
4+
5+
helper('empty-query', function (client) {
6+
it('handles empty query', function(done) {
7+
const stream = new QueryStream('-- this is a comment', [])
8+
const query = client.query(stream)
9+
query.on('end', function () {
10+
// nothing should happen for empty query
11+
done();
12+
}).on('data', function () {
13+
// noop to kick off reading
14+
})
15+
})
16+
17+
it('continues to function after stream', function (done) {
18+
client.query('SELECT NOW()', done)
19+
})
20+
})

0 commit comments

Comments
 (0)