662 Commits

Author SHA1 Message Date
Brian M. Carlson
da71ea58f6 Add query validity check
Passing nothing for both the query.text and query.name is unsupported but previously crashed with an impossible to catch error.
2017-06-18 17:15:46 -05:00
Brian M. Carlson
bd87cddc72 Fix connection / disconnection issues 2017-06-18 16:48:14 -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
313c41a39f Cleanup 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 Carlson
5f5e40f03c Add tests to support deprecated event listeners 2017-06-16 21:43:45 -05:00
Brian Carlson
fc3634045b Move attach listeners into its own function
Just for readability
2017-06-16 21:43:45 -05:00
Brian M. Carlson
2c3f55e5bd Make all tests pass 2017-06-15 10:32:38 -05:00
Brian M. Carlson
c961c900d6 Almost all tests passing 2017-06-15 10:32:38 -05:00
Brian M. Carlson
3219db993a All tests passing 2017-06-15 10:32:38 -05:00
Brian M. Carlson
72560850d7 Working on disconnect issue 2017-06-15 10:32:38 -05:00
Brian M. Carlson
3a7b226fe3 WIP 2017-06-15 10:32:38 -05:00
Brian M. Carlson
02bcc9d97a Start working on promsie tests 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
970d83aca4 Remove weird quasi-promise interface on JS query 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 M. Carlson
b8c2bebcac Fix more tests to use query instance 2017-06-15 10:32:38 -05:00
Brian M. Carlson
6d98b0847c Actual promisification of client.query 2017-06-15 10:32:38 -05:00
Brian M. Carlson
a829eee334 Merge origin/master 2017-06-09 16:24:39 -05:00
Brian M. Carlson
bbbd6e99f9 Use built-in util.deprecate 2017-06-09 15:41:27 -05:00
Brian M. Carlson
31ee7590fd Deprecate pg.* singleton methods 2017-06-09 15:41:27 -05:00
Brian Carlson
76c59a01f2 Emit error when backend unexpectedly disconnects 2017-06-09 12:27:47 -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
Brian C
f2b87e02f1 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.
2017-06-07 22:58:03 -05:00
Charmander
934ca3af16 Remove fallbacks for unsupported Node versions (#1304)
* Remove unsupported Node versions 0.10 and 0.12 from CI

* Replace deprecated Buffer constructor with .from/.alloc

* Remove Promise polyfill

* Make use of Object.assign

* Remove checks for versions of Node earlier than 4

* Remove Buffer#indexOf fallback for Node 0.10
2017-06-07 22:45:32 -05:00
Raul Ochoa
4cd56cc4f8 Make pool name consistent on missing config params (#1279)
* Going red: using a config object creates two pools when missing some params

It should only create a pool in a consistent way, even if some params
are not provided in the first place.

* Delay the pool name generation to make it consistent between calls

* Don't fallback to empty object as config is already defined
2017-05-24 09:04:50 -05:00
T.J. Schuck
e5f0e5d36a s/2016/2017/ (#1291) 2017-05-17 16:47:07 -05:00
Sehrope Sarkuni
ee8193673c Libpq connection string escaping (#1285)
* Fix escaping of libpq connection string properties

Fix handlings of libpq connection properties to properly escape single
quotes and backslashes. Previously the values were surrounded in single
quotes which handled whitespace within the property value, but internal
single quotes and backslashes would cause invalid connection strings to
be generated.

* Update expected output in test to be quoted

Update the expect host output in the connection parameter test
to expect it to be surrounded by single quotes.

* Add test for configs with quotes and backslashes
2017-05-15 12:19:13 -05:00
Kibae Shin
4f790deb73 Support for logical streaming replication (#1271)
* Support for logical streaming replication

* Wrong compare expr in getLibpqConnectionString

* Simplify codes for replication parameter
2017-04-24 13:24:30 -05:00
Ary Purnomoz
4505ae98d9 support ssl params for pg-native (#1169)
Make pg-native able to pass sslmode, sslca, sslkey and sslcert params to libpq
2017-04-19 09:55:56 -05:00
Magnus Hiie
197f86f90d Fix ECONNRESET error emitted after failed connect (#1230)
On Windows, after a connect attempt has failed, an error event with
ECONNRESET is emitted after the real connect error is propagated to the
connect callback, because the connection is not in ending state
(connection._ending) where ECONNRESET is ignored. This change ends the
connection when connect has failed.

This fixes #746.
2017-03-20 12:01:41 -05:00
Linus Unnebäck
ce8f215c88 Fix throw in type parsers when in prepared statement (#1242) 2017-03-09 15:05:26 -06:00
Linus Unnebäck
5cb38f5892 Handle throws in type parsers (#1218)
* Handle throws in type parsers

* Fix throw in type parsers test for Node 0.x
2017-03-06 11:04:16 -06:00
Charmander
41017814d3 Avoid infinite loop on malformed message (#1208)
* Avoid infinite loop on malformed message

If handling of such messages is deemed unimportant, `indexOf` is still faster (~40%) and cleaner than a manual loop.

Addresses #1048 to an extent.

* Use indexOf fallback for Node ≤0.12
2017-02-21 11:19:03 -06:00
Alexander Mochalin
f6c40b9331 parse int8[] (#1152)
* parse int8[]

* missing semicolon

* test

* test fixed

* test fixed

* test fixed. again.
2016-12-16 09:44:19 -06:00
Brian C
7f35240a5c Fix for utf-8 characters in md5 passwords (#1183)
This is the same fix as supplied in 1178 but includes a test.

Closes #1178
2016-12-13 11:51:36 -06:00
Charmander
981960b445 Remove confusing conditions (#1159)
* Remove unreachable code

* Remove redundant condition

Every path with `!this.values` results in `false` regardless of `this.binary`.
2016-12-13 07:50:07 -06:00
Charmander
5d821c3acb Use more correct escaping for array elements (#1177)
It’s not JSON.
2016-12-10 17:28:48 -06:00
Brian C
a536afb1a8 Add callback to client#end (#1106)
A long standing bug was the pure JS client didn't accept or call a callback on `client.end`.  This is inconsistent with both the documentation & general node patterns.

This fixes the issue & adds a test.  The issue did not exist in the native version of the client.
2016-08-11 10:17:03 -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
guoxiangyang
33a1c35ad2 changed for self signed ssl support (#1072) 2016-07-10 16:26:36 -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
812277f99f Fix native constructor and pool exports (#1061) 2016-06-24 00:52:28 -05:00
brianc
406357b9c6 Better indication that pg.pools is a private api 2016-06-21 22:03:25 -05:00