mirror of
https://github.com/brianc/node-postgres.git
synced 2025-12-08 20:16:25 +00:00
Implement handleEmptyQuery for pg-query-stream. (#2106)
This commit is contained in:
parent
823153138f
commit
c2f4b284b1
@ -15,6 +15,7 @@ class PgQueryStream extends Readable {
|
||||
this.handleCommandComplete = this.cursor.handleCommandComplete.bind(this.cursor)
|
||||
this.handleReadyForQuery = this.cursor.handleReadyForQuery.bind(this.cursor)
|
||||
this.handleError = this.cursor.handleError.bind(this.cursor)
|
||||
this.handleEmptyQuery = this.cursor.handleEmptyQuery.bind(this.cursor)
|
||||
}
|
||||
|
||||
submit(connection) {
|
||||
|
||||
20
packages/pg-query-stream/test/empty-query.js
Normal file
20
packages/pg-query-stream/test/empty-query.js
Normal file
@ -0,0 +1,20 @@
|
||||
const assert = require('assert')
|
||||
const helper = require('./helper')
|
||||
const QueryStream = require('../')
|
||||
|
||||
helper('empty-query', function (client) {
|
||||
it('handles empty query', function(done) {
|
||||
const stream = new QueryStream('-- this is a comment', [])
|
||||
const query = client.query(stream)
|
||||
query.on('end', function () {
|
||||
// nothing should happen for empty query
|
||||
done();
|
||||
}).on('data', function () {
|
||||
// noop to kick off reading
|
||||
})
|
||||
})
|
||||
|
||||
it('continues to function after stream', function (done) {
|
||||
client.query('SELECT NOW()', done)
|
||||
})
|
||||
})
|
||||
Loading…
x
Reference in New Issue
Block a user