Skip to content

Commit 28ca0b1

Browse files
committed
Drop support for EOL versions of node
1 parent 5cf8f5f commit 28ca0b1

File tree

6 files changed

+115
-132
lines changed

6 files changed

+115
-132
lines changed

.travis.yml

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@ addons:
1717

1818
matrix:
1919
include:
20-
- node_js: lts/carbon
21-
addons:
22-
postgresql: "9.5"
23-
dist: precise
24-
2520
# different PostgreSQL versions on Node LTS
2621
- node_js: lts/erbium
2722
addons:
@@ -35,9 +30,3 @@ matrix:
3530
- node_js: lts/erbium
3631
addons:
3732
postgresql: "9.6"
38-
39-
# PostgreSQL 9.2 only works on precise
40-
- node_js: lts/carbon
41-
addons:
42-
postgresql: "9.2"
43-
dist: precise

packages/pg-pool/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
"pg-cursor": "^1.3.0"
3535
},
3636
"peerDependencies": {
37-
"pg": ">5.0"
37+
"pg": ">8.0"
3838
}
3939
}

packages/pg-query-stream/test/async-iterator.es6

Lines changed: 0 additions & 112 deletions
This file was deleted.
Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,112 @@
1-
// only newer versions of node support async iterator
2-
if (!process.version.startsWith('v8')) {
3-
require('./async-iterator.es6')
4-
}
1+
const QueryStream = require('../')
2+
const pg = require('pg')
3+
const assert = require('assert')
4+
5+
const queryText = 'SELECT * FROM generate_series(0, 200) num'
6+
describe('Async iterator', () => {
7+
it('works', async () => {
8+
const stream = new QueryStream(queryText, [])
9+
const client = new pg.Client()
10+
await client.connect()
11+
const query = client.query(stream)
12+
const rows = []
13+
for await (const row of query) {
14+
rows.push(row)
15+
}
16+
assert.equal(rows.length, 201)
17+
await client.end()
18+
})
19+
20+
it('can async iterate and then do a query afterwards', async () => {
21+
const stream = new QueryStream(queryText, [])
22+
const client = new pg.Client()
23+
await client.connect()
24+
const query = client.query(stream)
25+
const iteratorRows = []
26+
for await (const row of query) {
27+
iteratorRows.push(row)
28+
}
29+
assert.equal(iteratorRows.length, 201)
30+
const { rows } = await client.query('SELECT NOW()')
31+
assert.equal(rows.length, 1)
32+
await client.end()
33+
})
34+
35+
it('can async iterate multiple times with a pool', async () => {
36+
const pool = new pg.Pool({ max: 1 })
37+
38+
const allRows = []
39+
const run = async () => {
40+
// get the client
41+
const client = await pool.connect()
42+
// stream some rows
43+
const stream = new QueryStream(queryText, [])
44+
const iteratorRows = []
45+
client.query(stream)
46+
for await (const row of stream) {
47+
iteratorRows.push(row)
48+
allRows.push(row)
49+
}
50+
assert.equal(iteratorRows.length, 201)
51+
client.release()
52+
}
53+
await Promise.all([run(), run(), run()])
54+
assert.equal(allRows.length, 603)
55+
await pool.end()
56+
})
57+
58+
it('can break out of iteration early', async () => {
59+
const pool = new pg.Pool({ max: 1 })
60+
const client = await pool.connect()
61+
const rows = []
62+
for await (const row of client.query(new QueryStream(queryText, [], { batchSize: 1 }))) {
63+
rows.push(row)
64+
break;
65+
}
66+
for await (const row of client.query(new QueryStream(queryText, []))) {
67+
rows.push(row)
68+
break;
69+
}
70+
for await (const row of client.query(new QueryStream(queryText, []))) {
71+
rows.push(row)
72+
break;
73+
}
74+
assert.strictEqual(rows.length, 3)
75+
client.release()
76+
await pool.end()
77+
})
78+
79+
it('only returns rows on first iteration', async () => {
80+
const pool = new pg.Pool({ max: 1 })
81+
const client = await pool.connect()
82+
const rows = []
83+
const stream = client.query(new QueryStream(queryText, []))
84+
for await (const row of stream) {
85+
rows.push(row)
86+
break;
87+
}
88+
for await (const row of stream) {
89+
rows.push(row)
90+
}
91+
for await (const row of stream) {
92+
rows.push(row)
93+
}
94+
assert.strictEqual(rows.length, 1)
95+
client.release()
96+
await pool.end()
97+
})
98+
99+
it('can read with delays', async () => {
100+
const pool = new pg.Pool({ max: 1 })
101+
const client = await pool.connect()
102+
const rows = []
103+
const stream = client.query(new QueryStream(queryText, [], { batchSize: 1 }))
104+
for await (const row of stream) {
105+
rows.push(row)
106+
await new Promise((resolve) => setTimeout(resolve, 1))
107+
}
108+
assert.strictEqual(rows.length, 201)
109+
client.release()
110+
await pool.end()
111+
})
112+
})

packages/pg/Makefile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,4 @@ test-pool:
6262

6363
lint:
6464
@echo "***Starting lint***"
65-
node -e "process.exit(Number(process.versions.node.split('.')[0]) < 8 ? 0 : 1)" \
66-
&& echo "***Skipping lint (node version too old)***" \
67-
|| node_modules/.bin/eslint lib
65+
node_modules/.bin/eslint lib

packages/pg/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,6 @@
5151
],
5252
"license": "MIT",
5353
"engines": {
54-
"node": ">= 4.5.0"
54+
"node": ">= 10.0.0"
5555
}
5656
}

0 commit comments

Comments
 (0)