Skip to content

Commit 0fa5cd8

Browse files
author
alxndrsn
committed
Merge branch 'master' into eslint-no-unreachable
2 parents b3e4e16 + 88311c1 commit 0fa5cd8

File tree

27 files changed

+217
-238
lines changed

27 files changed

+217
-238
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
44
#-------------------------------------------------------------------------------------------------------------
55

6-
FROM node:12
6+
FROM node:20
77

88
# Avoid warnings by switching to noninteractive
99
ENV DEBIAN_FRONTEND=noninteractive

.devcontainer/devcontainer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// If you want to run as a non-root user in the container, see .devcontainer/docker-compose.yml.
22
{
3-
"name": "Node.js 12 & Postgres",
3+
"name": "Node.js 20 & Postgres",
44
"dockerComposeFile": "docker-compose.yml",
55
"service": "web",
66
"workspaceFolder": "/workspace",

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto eol=lf

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ jobs:
4242
- '18'
4343
- '20'
4444
- '22'
45+
- '23'
4546
os:
4647
- ubuntu-latest
4748
name: Node.js ${{ matrix.node }}

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ For richer information consult the commit log on github with referenced pull req
44

55
We do not include break-fix version release in this file.
66

7+
8+
9+
- Add ability to specify query timeout on [per-query basis](https://github.com/brianc/node-postgres/pull/3074).
10+
711
812

913
- Add `queryMode` config option to [force use of the extended query protocol](https://github.com/brianc/node-postgres/pull/3214) on queries without any parameters.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,11 @@ This repo is a monorepo which contains the core [pg](https://github.com/brianc/n
1818
- [pg-connection-string](https://github.com/brianc/node-postgres/tree/master/packages/pg-connection-string)
1919
- [pg-protocol](https://github.com/brianc/node-postgres/tree/master/packages/pg-protocol)
2020

21+
## Install
22+
```
23+
npm install pg
24+
```
25+
2126
## Documentation
2227

2328
Each package in this repo should have its own readme more focused on how to develop/contribute. For overall documentation on the project and the related modules managed by this repo please see:

packages/pg-cursor/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "pg-cursor",
3-
"version": "2.12.0",
3+
"version": "2.12.3",
44
"description": "Query cursor extension for node-postgres",
55
"main": "index.js",
66
"directories": {
@@ -18,7 +18,7 @@
1818
"license": "MIT",
1919
"devDependencies": {
2020
"mocha": "^10.5.2",
21-
"pg": "^8.13.0"
21+
"pg": "^8.13.3"
2222
},
2323
"peerDependencies": {
2424
"pg": "^8"

packages/pg-native/bench/index.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ var warmup = function (fn, cb) {
1919
var native = Native()
2020
native.connectSync()
2121

22-
var queryText = 'SELECT generate_series(0, 1000)'
22+
var queryText = 'SELECT generate_series(0, 1000) as X, generate_series(0, 1000) as Y, generate_series(0, 1000) as Z'
2323
var client = new pg.Client()
2424
client.connect(function () {
2525
var pure = function (cb) {
@@ -36,12 +36,12 @@ client.connect(function () {
3636
}
3737

3838
var run = function () {
39-
var start = Date.now()
39+
console.time('pure')
4040
warmup(pure, function () {
41-
console.log('pure done', Date.now() - start)
42-
start = Date.now()
41+
console.timeEnd('pure')
42+
console.time('native')
4343
warmup(nativeQuery, function () {
44-
console.log('native done', Date.now() - start)
44+
console.timeEnd('native')
4545
})
4646
})
4747
}

packages/pg-native/lib/build-result.js

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ class Result {
99
this.rowCount = undefined
1010
this.fields = []
1111
this.rows = []
12+
this._prebuiltEmptyResultObject = null
1213
}
1314

1415
consumeCommand(pq) {
@@ -18,46 +19,47 @@ class Result {
1819

1920
consumeFields(pq) {
2021
const nfields = pq.nfields()
22+
this.fields = new Array(nfields)
23+
var row = {}
2124
for (var x = 0; x < nfields; x++) {
22-
this.fields.push({
23-
name: pq.fname(x),
25+
var name = pq.fname(x)
26+
row[name] = null
27+
this.fields[x] = {
28+
name: name,
2429
dataTypeID: pq.ftype(x),
25-
})
30+
}
2631
}
32+
this._prebuiltEmptyResultObject = { ...row }
2733
}
2834

2935
consumeRows(pq) {
3036
const tupleCount = pq.ntuples()
37+
this.rows = new Array(tupleCount)
3138
for (var i = 0; i < tupleCount; i++) {
32-
const row = this._arrayMode ? this.consumeRowAsArray(pq, i) : this.consumeRowAsObject(pq, i)
33-
this.rows.push(row)
39+
this.rows[i] = this._arrayMode ? this.consumeRowAsArray(pq, i) : this.consumeRowAsObject(pq, i)
3440
}
3541
}
3642

3743
consumeRowAsObject(pq, rowIndex) {
38-
const row = {}
44+
const row = { ...this._prebuiltEmptyResultObject }
3945
for (var j = 0; j < this.fields.length; j++) {
40-
const value = this.readValue(pq, rowIndex, j)
41-
row[this.fields[j].name] = value
46+
row[this.fields[j].name] = this.readValue(pq, rowIndex, j)
4247
}
4348
return row
4449
}
4550

4651
consumeRowAsArray(pq, rowIndex) {
47-
const row = []
52+
const row = new Array(this.fields.length)
4853
for (var j = 0; j < this.fields.length; j++) {
49-
const value = this.readValue(pq, rowIndex, j)
50-
row.push(value)
54+
row[j] = this.readValue(pq, rowIndex, j)
5155
}
5256
return row
5357
}
5458

5559
readValue(pq, rowIndex, colIndex) {
5660
var rawValue = pq.getvalue(rowIndex, colIndex)
57-
if (rawValue === '') {
58-
if (pq.getisnull(rowIndex, colIndex)) {
59-
return null
60-
}
61+
if (rawValue === '' && pq.getisnull(rowIndex, colIndex)) {
62+
return null
6163
}
6264
const dataTypeId = this.fields[colIndex].dataTypeID
6365
return this._types.getTypeParser(dataTypeId)(rawValue)

packages/pg-native/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"name": "pg-native",
3-
"version": "3.2.0",
3+
"version": "3.2.2",
44
"description": "A slightly nicer interface to Postgres over node-libpq",
55
"main": "index.js",
66
"scripts": {
77
"test": "mocha"
88
},
99
"repository": {
1010
"type": "git",
11-
"url": "git://github.com/brianc/node-pg-native.git"
11+
"url": "https://github.com/brianc/node-postgres.git"
1212
},
1313
"keywords": [
1414
"postgres",
@@ -18,18 +18,18 @@
1818
"author": "Brian M. Carlson",
1919
"license": "MIT",
2020
"bugs": {
21-
"url": "https://github.com/brianc/node-pg-native/issues"
21+
"url": "https://github.com/brianc/node-postgres/issues"
2222
},
23-
"homepage": "https://github.com/brianc/node-pg-native",
23+
"homepage": "https://github.com/brianc/node-postgres/tree/master/packages/pg-native",
2424
"dependencies": {
25-
"libpq": "1.8.13",
26-
"pg-types": "^1.12.1"
25+
"libpq": "1.8.14",
26+
"pg-types": "^2.1.0"
2727
},
2828
"devDependencies": {
2929
"async": "^0.9.0",
3030
"concat-stream": "^1.4.6",
3131
"generic-pool": "^2.1.1",
32-
"lodash": "^2.4.1",
32+
"lodash": "^4.17.21",
3333
"mocha": "10.5.2",
3434
"node-gyp": ">=10.x",
3535
"okay": "^0.3.0",

0 commit comments

Comments
 (0)