2015-06-01 15:45:02 -04:00
|
|
|
'use strict';
|
|
|
|
|
2018-10-15 22:29:53 -04:00
|
|
|
const tape = require('tape');
|
|
|
|
const stream = require('stream');
|
2021-03-08 07:16:07 -05:00
|
|
|
const { isPostgreSQL } = require('../util/db-helpers');
|
2015-06-01 15:45:02 -04:00
|
|
|
|
2020-04-19 00:40:23 +02:00
|
|
|
module.exports = function (knex) {
|
2021-03-08 07:16:07 -05:00
|
|
|
if (isPostgreSQL(knex)) {
|
2020-04-19 00:40:23 +02:00
|
|
|
tape('it streams properly in postgres', function (t) {
|
2018-10-15 22:29:53 -04:00
|
|
|
const w = new stream.Writable({
|
2018-07-09 08:10:34 -04:00
|
|
|
objectMode: true,
|
|
|
|
});
|
2020-04-19 00:40:23 +02:00
|
|
|
w._write = function (chunk, _, next) {
|
2015-06-01 15:45:02 -04:00
|
|
|
setTimeout(next, 10);
|
2018-07-09 08:10:34 -04:00
|
|
|
};
|
|
|
|
knex
|
|
|
|
.raw('select * from generate_series(0, 10, 1)')
|
|
|
|
.pipe(w)
|
2020-04-19 00:40:23 +02:00
|
|
|
.on('finish', function () {
|
2018-07-09 08:10:34 -04:00
|
|
|
t.ok(true, 'Streamed series');
|
|
|
|
t.end();
|
|
|
|
});
|
|
|
|
});
|
2015-06-01 15:45:02 -04:00
|
|
|
}
|
2018-07-09 08:10:34 -04:00
|
|
|
};
|