2646 Commits

Author SHA1 Message Date
Rafi Shamim
cf24ef28ee
pg-connection-string: avoid clobbering port from queryparams (#2833)
If the connection string is something like:
    postgresql://demo:password@/postgres?host=localhost&port=26258

Then the port from the query parameters should be used. Previously, the
parsing function would end up with a null port, and the default port
would end up being used by the connecetion package.
2023-07-21 11:57:02 -05:00
Ben Reinhart
3644730d2b
Remove early return for non commonjs environments (#3033) 2023-07-18 19:01:07 -05:00
Riku Rauhala
970804b6c1
Update pg-connection-string url in connecting.mdx (#3005) 2023-07-07 17:47:35 -05:00
dependabot[bot]
8d211e2be8
Bump workerd from 1.20230419.0 to 1.20230518.0 (#3023)
Bumps [workerd](https://github.com/cloudflare/workerd) from 1.20230419.0 to 1.20230518.0.
- [Release notes](https://github.com/cloudflare/workerd/releases)
- [Changelog](https://github.com/cloudflare/workerd/blob/main/RELEASE.md)
- [Commits](https://github.com/cloudflare/workerd/compare/v1.20230419.0...v1.20230518.0)

---
updated-dependencies:
- dependency-name: workerd
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-07 17:47:09 -05:00
dependabot[bot]
d17da9e1d9
Bump prettier from 2.7.1 to 2.8.8 (#3024)
Bumps [prettier](https://github.com/prettier/prettier) from 2.7.1 to 2.8.8.
- [Release notes](https://github.com/prettier/prettier/releases)
- [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/prettier/compare/2.7.1...2.8.8)

---
updated-dependencies:
- dependency-name: prettier
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-07 17:47:00 -05:00
Brian Carlson
eaafac36dc Publish
- pg-cloudflare@1.1.1
 - pg-connection-string@2.6.1
 - pg-cursor@2.10.1
 - pg-pool@3.6.1
 - pg-query-stream@4.5.1
 - pg@8.11.1
pg-cloudflare@1.1.1 pg-connection-string@2.6.1 pg-cursor@2.10.1 pg-pool@3.6.1 pg-query-stream@4.5.1 pg@8.11.1
2023-06-26 11:36:32 -05:00
Arian Mirahmadi
735683c5cb
Fix typo in project-structure.md (#3008) 2023-06-13 14:22:04 -07:00
Filipe Correa
46cfb25baf
Remove await from client release (#3006)
Co-authored-by: Filipe Correa <f.avelino-correa@klarna.com>
2023-06-12 12:50:40 -07:00
Riku Rauhala
e2d8fa2dc2
Fix a typo in README.md (#3002)
Change finanical to financial
2023-06-05 21:01:47 +00:00
Jason Ford
4dbf1af069
Add note about case sensitivity of result of pg.escapeIdentifier (#2993) 2023-06-01 01:03:50 -05:00
phiresky
d59cd15ed2
fix stack traces of query() to include the async context (#1762) (#2983)
* fix stack traces of query() to include the async context (#1762)

* rename tests so they are actually run

* conditionally only run async stack trace tests on node 16+

* add stack trace to pg-native

---------

Co-authored-by: Charmander <~@charmander.me>
2023-05-31 11:28:53 -05:00
Pete Bacon Darwin
0dfd955be5
fix: ensure that pg-cloudflare can be used with bundlers that don't know about Cloudflare sockets (#2978)
By implementing package.json `exports` we can avoid processing the Cloudflare
specific code, which contains `import ... from "cloudflare:sockets"`, in bundlers such
as Webpack.

If you are bundling for a Worker environment using Webpack then you need to add the
`workerd` condition and ignore `cloudflare:sockets` imports:

**webpack.config.js**
```js
resolve: { conditionNames: ["require", "node", "workerd"] },
  plugins: [
    new webpack.IgnorePlugin({
      resourceRegExp: /^cloudflare:sockets$/,
    }),
  ],
```
2023-05-31 11:25:56 -05:00
Rijk van Zanten
20d2c08027
Make async/await the primary examples in the docs (#2932)
* Correctly capitalize GitHub

* Add note on callbacks to index

* Add note on error handling

* Update client examples to use promises

* Update pooling examples

* Fix readme link

* Update cursor docs

* Update connecting examples

* Update Queries

* Update examples in pooling

* Update trx examples

* Update SSL example

* Update example

* Use ESM instead of CJS

* Update docs/pages/apis/cursor.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/apis/cursor.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/apis/pool.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/apis/pool.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/apis/pool.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/features/connecting.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/features/connecting.mdx

Co-authored-by: Charmander <~@charmander.me>

* Update docs/pages/features/ssl.mdx

Co-authored-by: Charmander <~@charmander.me>

---------

Co-authored-by: Charmander <~@charmander.me>
2023-05-31 11:25:24 -05:00
Novikov Evgeniy
dee3ae5cd6
feat: add connection parameter nativeConnectionString (#2941)
Co-authored-by: Evgeniy Novikov <e.p.novikov@tinkoff.ru>
2023-05-31 11:16:36 -05:00
Adam Jones
c38ecf3405
Fix connection string parsing for overriden hosts (#2977)
* Add failing test

* Fix test

This corresponds to what was line 48 previously, see https://github.com/brianc/node-postgres/pull/2971/files#diff-08a5e82487ebd9b43751630019753901fae0a111f8d009ad2e9d194445e96922L48

* Update packages/pg-connection-string/index.js

Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>

---------

Co-authored-by: Brian C <brian.m.carlson@gmail.com>
Co-authored-by: Pete Bacon Darwin <pete@bacondarwin.com>
2023-05-31 10:24:08 -05:00
Shane
65406985b9
Fix typo in types.mdx (#2989) 2023-05-29 12:07:05 -07:00
Charmander
3039f1da77 Revert "Update utils.js (#2981)"
This reverts commit 522e2dcb76f92d0096177b10204bdc385375020d.
2023-05-23 08:42:54 +00:00
sudarshanvn
522e2dcb76
Update utils.js (#2981)
Fixed following error

    ReferenceError: TextEncoder is not defined
2023-05-19 16:53:52 -05:00
Brian Carlson
14b840e96e Publish
- pg-cloudflare@1.1.0
 - pg-connection-string@2.6.0
 - pg-cursor@2.10.0
 - pg-query-stream@4.5.0
 - pg@8.11.0
pg-cloudflare@1.1.0 pg-connection-string@2.6.0 pg-cursor@2.10.0 pg-query-stream@4.5.0 pg@8.11.0
2023-05-15 10:36:31 -05:00
Pete Bacon Darwin
f2062936b9 Clean up pg-native in Makefile better 2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
7152d4db5d Add example Cloudflare Worker and test 2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
07553428e9 Add Cloudflare Worker compatible socket 2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
5532ca51db Use WebCrypto APIs where possible
The only place we are stuck with node's original crypto API
is for generating md5 hashes, which are not supported by WebCrypto.
2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
2b469d01da avoid accessing Node specific requires when not needed 2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
f305419676 Use URL rather than url.parse() in pg-connection-string
Swapping the deprecated Node.js API for the modern cross
environment API.
2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
26f7504531 fix invalid connection string test
The : and @ were the wrong way round
2023-05-15 07:29:07 +01:00
Pete Bacon Darwin
18b8ceae17 Add local development helper doc 2023-05-15 07:29:07 +01:00
Conner
249182ea9f
Document client.escapeIdentifier and client.escapeLiteral (#2954)
* Document client.escapeIdentifier and client.escapeLiteral

Per #1978 it seems that these client APIs are undocumented. Added documentation for these functions along with some examples and relevant links.

* Fix typos in new docs

* Migrate escapeIdentifier and escapeLiteral from Client to PG

These are standalone utility functions, they do not need a client instance to function.

Changes made:
- Refactored escapeIdentifer and escapeLiteral from client class to functions in utils
- Update PG to export  escapeIdentifier and escapeLiteral
- Migrated tests for Client.escapeIdentifier and Client.escapeLiteral to tests for utils
- Updated documentation, added a "utilities" page where these helpers are discussed

**note** this is a breaking change. Users who used these functions (previously undocumented) on instances of Client, or via Client.prototype.

* Export escapeIdentifier and escapeLiteral from PG

These are standalone utility functions, they should not depend on a client instance.

Changes made:
- Refactored escapeIdentifer and escapeLiteral from client class to functions in utils
- Re-exported functions on client for backwards compatibility
- Update PG to export  escapeIdentifier and escapeLiteral
- Updated tests to validate the newly exported functions from both entry points
- Updated documentation, added a "utilities" page where these helpers are discussed

* Ensure escape functions work via Client.prototype

Updated changes such that escapeIdentifier and escapeLiteral are usable via the client prototype
Updated tests to check for both entry points in client
2023-05-02 07:55:59 -05:00
Felix Rath
d63c761be8
docs(api/result): clarify that result.rowCount can be null (#2967)
`result.rowCount` is initialized to `null`, but only set to an `int`-value if the returned command tag consists of more than one word, which is not the case in general.

For example, the `LOCK` command will return a command tag of simply the form `LOCK`, and thus `result.rowCount` will stay `null`.
2023-05-01 09:15:55 -05:00
Brian C
0870442776
Fix race condition in release event test for pool (#2969) 2023-05-01 09:15:20 -05:00
Jan Piotrowski
b357e1884a
fix(theme.config.js): Replace default meta description and social title (#2952)
Currently still nextra default.

Those are shown in Slack and other social apps when sharing the website.
2023-04-20 16:03:59 +02:00
Brian C
48f4398fa7
Update README.md (#2944)
Update href to docs
2023-03-30 11:25:35 -05:00
Samuel Durante
92351b5f3e
docs(client): improve the Client instance example (#2935) 2023-03-30 10:49:28 -05:00
Ryan B. Harvey
65ca2458fd
Add release event to Pool API docs (#2928) 2023-03-16 11:34:50 -05:00
Brian C
0f76fb3bb7
Update path to documentation in readme (#2925) 2023-03-07 13:55:22 -06:00
Brian Carlson
661f870e1c Update changelog 2023-03-06 15:48:08 -06:00
Brian Carlson
ee302cbcf1 Publish
- pg-cursor@2.9.0
 - pg-pool@3.6.0
 - pg-query-stream@4.4.0
 - pg@8.10.0
pg-cursor@2.9.0 pg-pool@3.6.0 pg-query-stream@4.4.0 pg@8.10.0
2023-03-06 14:18:02 -06:00
Ryan B. Harvey
810b125581
Emit a 'release' event when a connection is released back to the pool (#2845) 2023-03-06 12:32:13 -06:00
Aram Zegerius
8804e5caaf
Fix typo in URL (#2913) 2023-03-06 12:30:37 -06:00
Cody Greene
5703791640
fix: double client.end() hang (#2717)
* fix: double client.end() hang

fixes https://github.com/brianc/node-postgres/issues/2716

`client.end()` will resolve early if the connection is already dead,
rather than waiting for an "end" event that will never arrive.

* fix: client.end() resolves when socket is fully closed
2023-03-06 12:10:07 -06:00
Brian Carlson
adbe86d4a0 Update changelog 2023-01-27 09:15:30 -06:00
Brian Carlson
20a243e8b3 Publish
- pg-cursor@2.8.0
 - pg-protocol@1.6.0
 - pg-query-stream@4.3.0
 - pg@8.9.0
pg-cursor@2.8.0 pg-protocol@1.6.0 pg-query-stream@4.3.0 pg@8.9.0
2023-01-27 09:12:49 -06:00
Brian Carlson
5bdc61a33d Remove expired sponsors 2023-01-27 09:11:05 -06:00
Brian C
47afe5cded
Attempt to fix timing test flake on older versions of node in CI (#2902) 2023-01-23 13:55:38 -08:00
Sehrope Sarkuni
bb8745b215
Fix SASL to bubble up errors, enable SASL tests in CI, and add informative empty SASL password message (#2901)
* Enable SASL tests in GitHub actions CI

* Add SASL test to ensure that client password is a string

* Fix SASL error handling to emit and bubble up errors

* Add informative error when SASL password is empty string
2023-01-23 10:03:51 -08:00
Ruy Adorno
f82f39c20c
Add support to stream factory (#2898)
This changeset enables declaring the `stream` config value as a factory
method. Providing a much more flexible control of the socket connection.

Defining a custom `stream` config value allows the postgres driver to
support a larger variety of environments/setups such as proxy servers
and secure socket connections that are used by cloud providers such as
GCP.

Currently, usage of the `stream` config value is only viable for single
connections given that it's only possible to define a single socket
stream instance per new Client/Pool instance. By adding support to a
factory function, it becomes possible to enable usage of custom socket
streams for connection pools.

For reference, see the `mysql2` driver for MySQL (linked below) for
prior art example of this pattern.

Refs: ba15fe2570/lib/connection.js (L63-L65)
Refs: https://cloud.google.com/sql/docs/postgres/connect-overview
Signed-off-by: Ruy Adorno <ruyadorno@google.com>

Signed-off-by: Ruy Adorno <ruyadorno@google.com>
2023-01-23 10:02:39 -08:00
Meron Ogbai
3e34816f6f
Update title (#2886)
This will change the title of the docs from Next.js Static Site Generator to node-postgres
2022-12-30 22:45:42 -06:00
dependabot[bot]
c6c05f823c
Bump JSONStream from 0.7.4 to 1.3.5 (#2874)
Bumps [JSONStream](https://github.com/dominictarr/JSONStream) from 0.7.4 to 1.3.5.
- [Release notes](https://github.com/dominictarr/JSONStream/releases)
- [Commits](https://github.com/dominictarr/JSONStream/commits)

---
updated-dependencies:
- dependency-name: JSONStream
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-30 22:02:45 -06:00
dependabot[bot]
16118cecdd
Bump eslint-config-prettier from 6.12.0 to 8.5.0 (#2875)
Bumps [eslint-config-prettier](https://github.com/prettier/eslint-config-prettier) from 6.12.0 to 8.5.0.
- [Release notes](https://github.com/prettier/eslint-config-prettier/releases)
- [Changelog](https://github.com/prettier/eslint-config-prettier/blob/main/CHANGELOG.md)
- [Commits](https://github.com/prettier/eslint-config-prettier/compare/v6.12.0...v8.5.0)

---
updated-dependencies:
- dependency-name: eslint-config-prettier
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-12-30 22:02:31 -06:00
Brian C
27d612a2ac
Update docs (#2867)
- fix config warnings
- add search bar
- add google analytics
2022-11-23 21:50:36 -06:00