312 Commits

Author SHA1 Message Date
Brian Carlson
95d7e620ef Publish
- pg-cursor@2.12.1
 - pg-query-stream@4.7.1
 - pg@8.13.1
2024-10-24 10:40:28 -05:00
Antariksh Mahajan
1af6321219
fix: use existing Result types for new Result (#3310)
* fix: use existing Result types for new Result

* test: add test for multiple results with custom type parser

* chore: empty commit to trigger tests
2024-10-23 17:05:33 -05:00
Brian Carlson
92cb640fd3 Publish
- pg-connection-string@2.7.0
 - pg-cursor@2.12.0
 - pg-native@3.2.0
 - pg-pool@3.7.0
 - pg-protocol@1.7.0
 - pg-query-stream@4.7.0
 - pg@8.13.0
2024-09-17 10:08:42 -05:00
Brian C
f73b22f96e
Handle bad message ordering - make it catchable. Fixes 3174 (#3289)
* Handle bad message ordering - make it catchable. Fixes 3174

* Close client in test

* Mess w/ github action settings

* update ci config

* Remove redundant tests

* Update code to use handle error event

* Add tests for commandComplete message being out of order

* Lint fix

* Fix native tests

* Fix lint again...airport computer not my friend

* Not a native issue
2024-09-17 09:50:17 -05:00
dependabot[bot]
fb12280340
Bump bluebird from 3.4.1 to 3.7.2 (#3303)
Bumps [bluebird](https://github.com/petkaantonov/bluebird) from 3.4.1 to 3.7.2.
- [Release notes](https://github.com/petkaantonov/bluebird/releases)
- [Commits](https://github.com/petkaantonov/bluebird/compare/v3.4.1...v3.7.2)

---
updated-dependencies:
- dependency-name: bluebird
  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>
2024-09-17 09:31:21 -05:00
dependabot[bot]
54eb0fa216
Bump mocha and @types/mocha (#3273)
Bumps [mocha](https://github.com/mochajs/mocha) and [@types/mocha](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/HEAD/types/mocha). These dependencies needed to be updated together.

Updates `mocha` from 3.4.2 to 10.5.2
- [Release notes](https://github.com/mochajs/mocha/releases)
- [Changelog](https://github.com/mochajs/mocha/blob/main/CHANGELOG.md)
- [Commits](https://github.com/mochajs/mocha/compare/v3.4.2...v10.5.2)

Updates `@types/mocha` from 5.2.7 to 10.0.7
- [Release notes](https://github.com/DefinitelyTyped/DefinitelyTyped/releases)
- [Commits](https://github.com/DefinitelyTyped/DefinitelyTyped/commits/HEAD/types/mocha)

---
updated-dependencies:
- dependency-name: mocha
  dependency-type: direct:development
  update-type: version-update:semver-major
- dependency-name: "@types/mocha"
  dependency-type: direct:development
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-07-25 12:20:59 -05:00
Brian C
50c06f9bc6
Remove test globals (#3264)
* Remove assert from globals

* Remove Client from globals

* Remove global test function

* Remove MemoryStream from globals

* Require assert in SASL integration tests

* Attempt to use a postgres with ssl?

* Use latest image

* Remove connection tests - they test internals that are better covered by testint the client
2024-06-19 13:46:16 -05:00
Pete Bacon Darwin
f7e484ed61
refactor: tighten up cloudflare detection (#3170)
* refactor: tighten up cloudflare detection

The previous approach to detecting whether to use Cloudflare's sockets was to check for missing polyfills.
But as we improve the polyfills that Wrangler can provide these checks are no longer valid.

Now we just try to use the Cloudflare API first and fallback to Node.js if those are not available.

* fixup! refactor: tighten up cloudflare detection
2024-06-19 13:28:01 -05:00
Brian C
3e4d545c20
Fix lint (#3262) 2024-06-19 09:45:52 -05:00
srieding
9baa56eaa2
feat: allow specifying a timeout on a per query base (#3074) 2024-06-19 09:36:35 -05:00
Alex Anderson
4f457e12e0
Remove unused file: list-db-types (#3249)
Co-authored-by: alxndrsn <alxndrsn>
2024-06-19 09:32:52 -05:00
Brian C
53dc4e6cb3
Add test for date type (#3261) 2024-06-19 09:32:16 -05:00
Alex Anderson
83a0e3e90e
eslint: enable rule: @typescript-eslint/no-unused-vars (#3247)
When enabling this rule, it's recommended to also *disable* the standard `no-unused-vars` rule.  Although `no-unused-vars` is not currently enabled, it seems helpful to explicitly disable it here.

See: https://typescript-eslint.io/rules/no-unused-vars/

Co-authored-by: alxndrsn <alxndrsn>
2024-06-18 15:55:17 -05:00
Alex Anderson
a24a24dea1
test/connection/inbound-parser: remove unused vars (#3245)
Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 11:00:26 -05:00
Alex Anderson
d650741eea
lib/client: remove no-op statement (#3240)
This looks like it was a refactoring of

  var connectionTimeoutHandle;

Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 11:00:04 -05:00
Alex Anderson
e4cb1cdc38
client/escape-tests: remove unused function (#3244)
Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 10:51:56 -05:00
Alex Anderson
cd73e9bf86
pg-native/test: remove unused "done" arg from describe() calls (#3242)
Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 10:51:34 -05:00
Alex Anderson
f2279f3529
pg-connection-string/test: remove unused var (#3243)
Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 10:51:13 -05:00
Alex Anderson
1625861981
Remove unused imports (#3241)
* Remove unused imports

* reinstate test helper

---------

Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 10:50:52 -05:00
Alex Anderson
6e96e45bae
test/type-coercion: fix typo in test title (#3237)
`timestamptz` was written `timestampz`

Co-authored-by: alxndrsn <alxndrsn>
2024-06-05 10:50:16 -05:00
Brendan Irvine-Broque
5c846ca06e
Clarify usage and update readme (#3114)
refs https://github.com/Ethan-Arrowood/socket/pull/17

@petebacondarwin @brianc — publishing `pg-cloudflare` as a separate package seems to be really helpful to people. Ex:

https://github.com/sidorares/node-mysql2/pull/2289/files#diff-e56fabfb5e90fd8f6265cfbe84f3701a85261d884e198bf61de34958cee4864aR12

Added some docs to clarify usage, and cross link to the Node.js implementation of the Socket API.

Co-authored-by: Brian Carlson <brian.m.carlson@gmail.com>
2024-06-04 11:49:30 -05:00
Brian C
7fcf941a33
Improve race condition in pg-native cancel test (#3234) 2024-06-04 11:39:52 -05:00
Brian Carlson
0f42880861 Publish
- pg-cursor@2.11.0
 - pg-native@3.1.0
 - pg-query-stream@4.6.0
 - pg@8.12.0
2024-06-04 11:19:08 -05:00
Alex Anderson
ff47a97f28
Add option to force use of Extended Queries (#3214)
This feature can be used as follows:

```
client.query({ text: 'SELECT 1', queryMode: 'extended' })
```

This will force the query to be sent with parse/bind/execute even when it has no parameters and disallows multiple statements being executed.  This can be useful in scenarios where you want to enforce more security & help prevent sql injection attacks...particularly by library authors.

---------

Co-authored-by: alxndrsn <alxndrsn>
Co-authored-by: Brian Carlson <brian.m.carlson@gmail.com>
2024-06-04 11:14:04 -05:00
Brian C
fe88e825e5
Add pg-native to monorepo (#3225)
I didn't do much to "modernize" the pg-native codebase other than running it through the standard eslint --fix that is applied to the rest of the code. There's some easy opportunities there to update it to es6 and so on...it still uses some pretty antiquated coding styles in places.  This PR re-introduces the native tests on node v20, and updates test matrix to drop unsupported versions of node & add in node v22.
2024-06-04 10:26:11 -05:00
Juan GP
0096856e2e
reorder user-password-host-port-database appearences (#3207) 2024-05-10 12:03:11 -05:00
Brian Carlson
a37a93bf79 Publish
- pg-connection-string@2.6.4
 - pg-cursor@2.10.5
 - pg-query-stream@4.5.5
 - pg@8.11.5
2024-04-02 15:26:02 -05:00
Brian C
95655fea0b
Revert "fix: conflict between browser URL object and Node URL object (#3061)" (#3188)
This reverts commit d21cc09556899b8038ec23613a801c19228637ca.
2024-04-02 15:23:53 -05:00
Brian Carlson
b03c071d2d Publish
- pg-connection-string@2.6.3
 - pg-cursor@2.10.4
 - pg-pool@3.6.2
 - pg-protocol@1.6.1
 - pg-query-stream@4.5.4
 - pg@8.11.4
2024-03-30 15:40:05 -05:00
Charmander
5807a00d93
Remove unused protocol-related dependencies from pg (#3181)
buffer-writer was replaced with pg-protocol in 3ff91eaa3222657fd51ea463b8086d134a505404, and packet-reader in 520bd3531990f32c3e00b20020c67f6ac6c70261.
2024-03-29 21:35:50 -05:00
Alex Anderson
2ab6f367c0
query: remove unused prop: isPreparedStatement (#3177)
Use of this property was removed in 2020 (dd3ce616d0fbdb92a7e146ecf4171bf3c1b3ea97).

Co-authored-by: alxndrsn <alxndrsn>
2024-03-28 10:28:30 -05:00
Alex Anderson
b400d33c33
query: remove unused prop: _promise (#3178)
Use of this prop was probably removed in 2017 (a0eb36d81938e488b3bc5369faee74fe22f36949).

Co-authored-by: alxndrsn <alxndrsn>
2024-03-28 10:26:00 -05:00
Alex Anderson
91de4b9453
Cursor: avoid closing connection twice if error received after destroy() (#2836)
* Cursor: avoid closing connection twice if error received after destroy()

Includes test case from @nathanjcochran

* Resolve lint violations

* revert fix to check tests fail without it

* Re-introdce fix

This reverts commit 5f5d42a071e40f8851035dba182642937dd35664.

---------

Co-authored-by: alxndrsn <alxndrsn>
2024-03-15 12:26:25 -05:00
Alex Anderson
a717c00b7b
chore (ci): add node v20 to build matrix (#3148)
* chore (ci): add node v20 to build matrix

* skip pg-native tests on node 20

---------

Co-authored-by: alxndrsn <alxndrsn>
2024-03-15 12:05:15 -05:00
Sehrope Sarkuni
b4bfd63f63
CI clean up to fix lint task and remove Windows / MacOS from matrix (#3122)
* Remove unused travis CI config

* Bump eslint and friends

* Fix lint errors after eslint upgrade

* Remove windows and macos from CI workflow as they are actually running linux

Removes the windows and macos matrix from the CI workflow as they were never actually setting
the OS. Both were running against the "ubuntu-latest" OS. Trying to actually use them would
not work either as neither windows or macos is supported for service containers. A different
means will be needed to test on those platforms. Until that's done, this removes those from
the matrix as we were simply running the same thing 3x for the same node versions.
2024-03-05 14:08:44 -06:00
Shane da Silva
81c287a49b
Serialize arrays of Uint8Array objects as hex escape sequences (#2930)
Previously, if you attempted to pass an array of `Uint8Array` objects to
a prepared statement, it would render each literal numeric value of that
array.

Since `Uint8Array` (and `TypedArray` types) represent views over raw
bytes, ensure these are serialized to Postgres as a byte representation.
2024-02-09 21:25:41 -08:00
Tunçer Damat
df0f4d19fb
Correction of the "e" variable to "err" in snippet (#3123) 2024-01-10 08:22:00 -08:00
Alex Anderson
16322c2d50
Fix eslint violations (#3078)
Co-authored-by: alxndrsn <alxndrsn>
2023-10-19 10:27:25 -05:00
Romain Gilliotte
b1a8947738
Fail gracefully when connecting to other database (#3026)
* Fail gracefully when connecting to other SGDB vendor

* Make test more flexible. Adjust error wording to match native better.

---------

Co-authored-by: Brian Carlson <brian.m.carlson@gmail.com>
2023-09-15 16:23:05 -05:00
Sebastien Stettler
d21cc09556
fix: conflict between browser URL object and Node URL object (#3061)
I am running this package using electron, what i noticed was that due to
the fact that the lines between node and browser environments become a
bit blurred, the URL class that was being used was the one defined by
the browser and not node. By making an explicit require it ensures the
correct Class is used.

While creating a test for this would be difficuilt i think adding an
eslint rule to stop using globally defined objects and require imports
instead would resolve issues like this in the future
2023-09-15 16:22:18 -05:00
Brian C
da0f5c5eb2
Remove 1 loop on rowDescription event (#3056)
* Remove 1 loop on rowDescription event

* Update packages/pg/lib/result.js

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

---------

Co-authored-by: Charmander <~@charmander.me>
2023-09-15 16:21:45 -05:00
Sehrope Sarkuni
106ca8a178
Fix get value of last column with same name in result rows (#3063)
* Add failing test for result rows with the same column names

* Fix handling of duplicate column names in results to ensure last value is populated

Fixes handling of result rows that have the same column name duplicated in the results to ensure
that the last value is the one returned to the user. This was the old behavior but unintentionally
broken when the pre-built object optimization was added.
2023-09-14 14:43:14 -05:00
Brian Carlson
a84ebb3fe8 Publish
- pg-cursor@2.10.3
 - pg-query-stream@4.5.3
 - pg@8.11.3
2023-08-16 16:50:05 -07:00
Koen
b5c5e52aa0
Option to use pre-shaped result rows; fixes #3042 (#3043)
* Add property usePrebuiltEmptyResultObjects to Query constructor which generates pre-shaped result rows

* Remove option and test for prebuiltEmptyResultObject

* Remove errorneously added newline

* Move all logic for prebuilding objects to Result

* Move prebuilding to addFields

* Use a clone as clone-base

---------

Co-authored-by: HZ111 / Dev2 <hz111@wielick.nl>
2023-08-15 08:42:54 -07:00
Brian Carlson
a2a355a680 Publish
- pg-connection-string@2.6.2
 - pg-cursor@2.10.2
 - pg-query-stream@4.5.2
 - pg@8.11.2
2023-07-31 22:36:33 -05:00
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
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
2023-06-26 11:36:32 -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