89 Commits

Author SHA1 Message Date
André Cruz
eb076db5d4 Add configurable query timeout (#1760)
* Add read_timeout to connection settings

* Fix uncaught error issue

* Fix lint

* Fix "queryCallback is not a function"

* Added test and fixed error returning

* Added query timeout to native client

* Added test for timeout not reached

* Ensure error is the correct one
Correct test name

* Removed dubious check

* Added new test

* Improved test
2018-11-29 09:11:47 -06:00
Charmander
1cf1e05ab9 Allow a custom type to be used for Client promises (#1518)
Matches the Pool API.
2018-10-24 10:40:23 -05:00
Charmander
3828aa8608 Queued query errors (#1503)
* Add tests for query callbacks after connection-level errors

* Ensure callbacks are executed for all queued queries after connection-level errors

Separates socket errors from error messages, sends socket errors to all queries in the queue, marks clients as unusable after socket errors.

This is not very pleasant but should maintain backwards compatibility…?

* Always call `handleError` asynchronously

This doesn’t match the original behaviour of the type errors, but it’s correct.

* Fix return value of `Client.prototype.query` in immediate error cases

* Mark clients with closed connections as unusable consistently

* Add tests for error event when connecting Client

* Ensure the promise and callback versions of Client#connect always have the same behaviour

* Give same error to queued queries as to active query when ending

and do so in the native Client as well.

* Restore original ordering between queued query callbacks and 'end' event
2018-10-03 10:37:15 -05:00
Billouboq
5062f275a7 remove unused variable
test
2017-07-19 00:48:20 +02:00
Brian M. Carlson
111e08d0d7 Cleanup 2017-07-16 16:25:35 -05:00
Brian M. Carlson
ac3102eea2 Add support for pg-native multi-row result 2017-07-16 16:25:35 -05:00
Brian C
8798e50ad3 Re-enable eslint with standard format (#1367)
* Work on converting lib to standard

* Finish updating lib

* Finish linting lib

* Format test files

* Add .eslintrc with standard format

* Supply full path to eslint bin

* Move lint command to package.json

* Add eslint as dev dependency
2017-07-15 12:05:58 -05:00
Brian M. Carlson
f7de9ce820 Non-array query values cause query to end with an error.
This is a small change and is _kinda_ backwards compatible since the old behavior was to throw an error, but if someone was relying on anything with `.map` working as values it would break them, so it's in a major semver bump.
2017-07-15 11:19:37 -05:00
Brian Carlson
27450d07e6 Throw on reconnect attempt
Clients are not reusable.  This changes the client to raise errors whenever you try to reconnect a client that's already been used.  They're cheap to create: just instantiate a new one (or use the pool) 😉.

Closes #1352
2017-07-15 11:02:09 -05:00
Brian M. Carlson
0f1f8626cf Add use strict to every file 2017-06-18 16:48:14 -05:00
Brian M. Carlson
2300445646 Cleanup a bit of dead code 2017-06-18 16:48:14 -05:00
Brian M. Carlson
1bc1758579 Remove deprecated methods 2017-06-18 16:48:14 -05:00
Brian M. Carlson
cfd9caa925 Deprecate query.on & query.once 2017-06-16 21:43:45 -05:00
Brian M. Carlson
76c1000567 Add event-emitters back 2017-06-16 21:43:45 -05:00
Brian M. Carlson
c961c900d6 Almost all tests passing 2017-06-15 10:32:38 -05:00
Brian M. Carlson
bc2f550402 Remove promise-interop from native query 2017-06-15 10:32:38 -05:00
Brian M. Carlson
55c3b3691c Use normalizeQueryConfig in native query 2017-06-15 10:32:38 -05:00
Brian M. Carlson
df36bece86 Restructure native file paths
Make file paths more closely match the non-native files, to make auto-complete file names slightly easier.
2017-06-15 10:32:38 -05:00
Brian M. Carlson
d3ec938b82 Fix remainder of error tests 2017-06-15 10:32:38 -05:00
Brian M. Carlson
2add7e3407 Make almost all tests pass 2017-06-15 10:32:38 -05:00
Brian C
aeb0c759f5 Remove fallbacks for unsupported Node versions (#1304) (#1313)
* Add client connectionString tests (#1310)

* Remove redundant tests

* Add client connectionString test

Add test to ensure { connectionString } is respected as an argument to the client constructor

* Add test for connection string property

Also fixed some legacy require statements.

* Normalize native error properties

Map native error properties to the same property names we use for errors from the JS driver.

Fixes #972
Fixes #938
2017-06-08 21:53:47 -05:00
T.J. Schuck
e5f0e5d36a s/2016/2017/ (#1291) 2017-05-17 16:47:07 -05:00
Brian C
b1b2801c71 Add onFailure to query#then (#1082)
The promise adapter I had implemented wasn't spec compliant: it didn't accept both `onSuccess` and `onFailure` in the call to `query#then`.  This subtly broke yield & async/await because they both rely on `onError` being passed into `Promise#then`.  The pool was also not returning the promise after a client was acquired, which broke awaiting on `pool.connect` - this is also fixed now.
2016-07-19 10:16:48 -05:00
Illirik Smirnov
522d62229b Resolve merge conflict in PR #1041 (#1065)
* Add license comment

* Delete pool.js
2016-06-24 10:56:43 -05:00
Brian C
2fd9c77085 Make Query & NativeQuery implement the promise interface (#1047)
* Make Query & NativeQuery implement the promise interface

* Fix test

* Use older node API for checking listener length

* Do not test for promises on node@v0.10.0
2016-06-10 17:18:19 -05:00
Frederick Stark
b78a508420 Add function stub to native result to solve broken test 2016-02-12 13:38:38 +11:00
Joost Farla
f50f5ce7e8 Require statements break Browserify compatibility 2015-10-10 11:10:51 +02:00
brianc
17f14f4e58 Add warning for native bindings 2015-06-07 10:20:48 -04:00
Mayhem
37956e22c5 Fix result.rowCount being a string instead of a number via native bindings.
Fixes #708
2015-02-21 17:32:39 +01:00
David H. Bronke
4bfdc041ef Moved type override code into a new class. 2014-12-03 11:00:27 -06:00
David H. Bronke
a0bf25e308 Implemented per-client type parser overrides.
Adds Client#getTypeParser() and Client#setTypeParser().
2014-12-03 10:38:57 -06:00
Brian M. Carlson
06b0392a57 Update travis config 2014-11-18 11:51:40 -05:00
Brian M. Carlson
35596fdbdc Upgrade version of pg-native 2014-11-18 09:32:16 -05:00
Brian M. Carlson
21f6dbe006 Break native result into its own file 2014-10-18 00:27:28 -04:00
Brian M. Carlson
5dff31387c Remove dead file 2014-10-18 00:21:39 -04:00
Brian M. Carlson
c3513a27fa Make native bindings an optional install 2014-10-18 00:20:18 -04:00
Brian M. Carlson
89d0938655 Subscribe to notification before emitting connected
Fixes a case where you connect & immediatley disconnect and _sometimes_ your notification subscription starts the reader on the libpq instance after the libpq instance is disconnected.  This segfaults the app.
2014-10-17 23:09:55 -04:00
Brian M. Carlson
4c5f3aba65 Add support for native rowMode: array
This completes the port from the old native bindings to the new node-pg-native bindings!

Time to build in support for older versions of postgres & start the pull request process.
2014-10-11 14:09:29 -04:00
Brian M. Carlson
613112ca33 Upgrade to pg-native 1.2.0 to support rowMode:array 2014-10-09 21:54:34 -04:00
Brian M. Carlson
3867851341 Make cancel query tests pass 2014-10-09 21:12:17 -04:00
Brian M. Carlson
c5d4207aac Fix a few more failing tests 2014-09-23 18:57:20 -04:00
Brian M. Carlson
d2bb532d73 Make moar tests pass 2014-09-14 21:11:51 -04:00
Brian M. Carlson
667c528ea6 Work towards more tests passing 2014-09-14 01:23:02 -04:00
Brian M. Carlson
b325971fdf Make more tests pass 2014-09-13 22:37:30 -04:00
Brian M. Carlson
9a68682109 First tests passing for new native bindings 2014-09-13 12:32:53 -04:00
Philipp Borgers
fa3b1ccc5b remove pause/resumeDrain functions from native code as disccued in issue #515 2014-04-16 19:10:49 +02:00
Brian M. Carlson
9c87253aff Fix memory leak with domains 2014-04-12 00:29:44 -05:00
Brian M. Carlson
bd74d48791 Fix query error emit on native bindings 2014-04-06 12:55:26 -05:00
Brian M. Carlson
876abe8730 Break type parsing into separate module 2014-03-15 15:36:27 -05:00
rpedela
cd4565ba1f #181 #366 Add support for single row mode in Postgres 9.2+. This will enable single row mode only when the user wants to stream rows. 2013-09-04 11:46:07 -06:00