Brian M. Carlson
bd74d48791
Fix query error emit on native bindings
2014-04-06 12:55:26 -05:00
Brian M. Carlson
357b64d704
Remove query emit 'end' event when query has error
...
Closes #547
2014-04-06 11:53:47 -05:00
Brian C
f3fc6ff705
Merge pull request #546 from CartoDB/2.11-ensure-connect-callback
...
Ensure connect callback is invoked on premature socket hangup
2014-04-06 11:18:23 -05:00
Brian C
82486929a9
Merge pull request #555 from benesch/custom-type-coercion
...
Supercharge `prepareValue`
2014-04-06 11:16:33 -05:00
Sandro Santilli
e1b1c62e3e
Do not emit 'end' twice from Connection on close
2014-04-04 10:07:07 +02:00
Nikhil Benesch
619ba46ffe
pass prepareValue
hook to toPostgres
...
Pass `toPostgres` type-coercers a reference to the `prepareValue`
function to ease constructing literals composed of other Postgres types.
2014-04-03 10:28:02 -04:00
Brian C
7dbc4c9845
Merge pull request #552 from geon/patch-1
...
Added missing argument to handleError method call.
2014-04-03 08:58:48 -05:00
Nikhil Benesch
6ced524390
allow type-coercion overrides for custom objects
...
Attempt to call a `toPostgres` method on objects passed as query values
before converting them to JSON. This allows custom types to convert
themselves to the appropriate PostgreSQL literal.
This strategy is fully backwards-compatible and uses the same pattern as
the `toJSON` override.
2014-03-30 20:39:56 -04:00
Nikhil Benesch
c41eedc3e0
properly prepare complex arrays
...
`arrayString` duplicated too much of `prepareValue`'s logic, and so
didn't receive bugfixes for handling dates with timestamps. Defer to
`prepareValue` whenever possible.
This change enforces double-quote escaping of all array elements,
regardless of whether escaping is necessary. This has the side-effect of
properly escaping JSON arrays.
2014-03-30 19:12:18 -04:00
Nikhil Benesch
364cf4b3ca
utils: convert tabs to spaces
2014-03-30 19:11:02 -04:00
Nikhil Benesch
7faa2b325e
utils: reorganize prepareValue conditional for clarity
...
Prefer positive tests; group tests for specific objects.
2014-03-30 19:03:28 -04:00
Nikhil Benesch
cb7bbe6502
query: remove dead type-parsing code path
...
Type parsing was factored out into the pg-types package. Remove vestigal
`noParse` function.
2014-03-30 19:02:11 -04:00
Victor Widell
5079c1e0c4
Added missing argument to handleError method call.
...
Before the change, it would crash with a very unhelpful error message:
[project path]/node_modules/pg/lib/query.js:92
connection.sync();
^
TypeError: Cannot call method 'sync' of undefined
at Query.handleError ([project path]/node_modules/pg/lib/query.js:92:16)
at Client.connect ([project path]/node_modules/pg/lib/client.js:178:24)
at g (events.js:185:14)
at EventEmitter.emit (events.js:85:17)
at Socket.<anonymous> ([project path]/node_modules/pg/lib/connection.js:60:10)
at Socket.EventEmitter.emit (events.js:85:17)
at TCP.onread (net.js:424:51)
After the change, it reports a much more helpful
error running query [Error: Stream unexpectedly ended during query execution]
2014-03-29 16:45:00 +01:00
Brian C
b12dd4c420
Merge pull request #543 from CartoDB/2.11-remove-ended-connections
...
Remove disconnected clients from the pool
2014-03-22 10:47:53 -05:00
Sandro Santilli
96e4afdb1b
Have Connection also emit 'end' on stream 'close' event
...
Should fix missing connect callback call with node-0.8 (#534 )
2014-03-18 14:23:05 +01:00
Sandro Santilli
64d6883a81
Ensure connect callback is invoked on premature socket hangup
...
Closes #534
2014-03-18 13:03:15 +01:00
Sandro Santilli
fb118cf069
Avoid loop between pool.destroy and client.end
2014-03-18 09:42:19 +01:00
Sandro Santilli
9c5cd8d02d
Remove disconnected clients from the pool
...
Might fix #458
Fixes https://github.com/CartoDB/CartoDB-SQL-API/issues/135
2014-03-17 18:51:32 +01:00
Brian M. Carlson
779c8064f2
Add domain support to connection pool
2014-03-15 16:41:33 -05:00
Brian M. Carlson
0254fa565f
Add test for pg.types interface
2014-03-15 15:41:36 -05:00
Brian M. Carlson
876abe8730
Break type parsing into separate module
2014-03-15 15:36:27 -05:00
Brian M. Carlson
79f03948dd
Use packet reader
2014-03-14 06:59:19 -05:00
Brian C
2716f95257
Merge pull request #514 from benighted/parse-date-as-local
...
Parse date type as local time
2014-02-26 06:16:12 -06:00
Brian C
ff8fb616f6
Merge pull request #501 from lalitkapoor/GH-452
...
improve support for int arrays and float arrays
2014-02-26 06:15:35 -06:00
Brian C
be37756607
Merge pull request #395 from aaronyo/master
...
Unable to reconnect after calling pg.end()
2014-02-26 06:12:57 -06:00
Brian M. Carlson
bf0c4bfaa9
Merge branch 'pull/326'
...
Conflicts:
lib/connection-parameters.js
test/unit/connection-parameters/creation-tests.js
2014-02-26 06:10:15 -06:00
Michael Payne
b81a60a260
Parse date type as local time
2014-01-26 10:43:15 -05:00
Brian C
62f6b2fbf9
Merge pull request #507 from brianc/issues/507
...
Unexpected identifier with pg versions > 2.3.1
2014-01-22 06:42:59 -08:00
Brian M. Carlson
5f592a1240
Fix exception caused by column names with single quotes
...
Also rename some test files so they match the Makefile regex. They will be included in the test suite from now on.
2014-01-22 08:38:29 -06:00
Lalit Kapoor
8f4644dc3d
parse values in float arrays as floats not strings
...
javascript numbers are 64-bit floating numbers
2014-01-08 00:09:34 -06:00
Lalit Kapoor
3cb35e0f46
big integer array support
2014-01-08 00:08:57 -06:00
Lalit Kapoor
58b4d9cf9c
comment explaining how to get oid
2014-01-07 11:48:55 -06:00
Hannes Hörl
7fd79a41c3
Add support for (fallback_)application_name
2014-01-05 18:08:58 +01:00
Hannes Hörl
5c5c57e60b
Fixes bug in test for extended years
2013-12-23 02:13:10 +01:00
Hannes Hörl
9ad0159037
merge with upstream
2013-12-22 23:21:42 +01:00
Aurélio A. Heckert
c0fd4b1431
Set database on socket string connection
...
Allows to conect to a specific database trough this ways:
pg.connect('/some/path database', callback);
pg.connect('socket:/some/path?db=database', callback)
pg.connect('socket:/some/path?db=database&encoding=utf8', callback)
2013-12-19 15:37:26 -03:00
Hannes Hörl
61f8f55d43
Handle .pgpass in the native client
2013-12-11 01:24:55 +01:00
Michael Payne
b9c9c6f329
Fix for Y10k problem
2013-12-09 23:35:18 -05:00
Hannes Hörl
95295ad2fb
Handle .pgpass in the js client
2013-12-06 00:01:51 +01:00
Brar Piening
d5e459227a
Modified defaults.js to use process.env.USERNAME instead of process.env.USER as default value for user and database on Windows platforms
2013-11-20 20:19:31 +01:00
Brian M. Carlson
99f9492c72
Clean up copy-in internal API
2013-10-22 00:23:43 -05:00
Brian M. Carlson
894c60e605
Accept anything with function 'submit' as a query
...
This allows for passing in custom objects which conform to the query API
2013-10-21 13:29:17 -05:00
Brian M. Carlson
a72bd5cb3c
Semi-colons
2013-10-21 09:39:49 -05:00
Brian M. Carlson
fc397ee7f5
Clean up client->query event delegation
2013-10-21 09:20:21 -05:00
Albert Łącki
96018dbfae
FIXED for jshint
2013-10-17 03:06:31 +02:00
Albert Łącki
67a47b9025
Parse arrays: json[], uuid[]
2013-10-16 07:03:43 +02:00
Brian C
aea984f7bc
Merge pull request #447 from eugeneware/buffer-params
...
Bind Buffer Variables as binary values (with Native implementation also)
2013-10-02 20:32:03 -07:00
Brian C
4fcfc66a45
Merge pull request #423 from rpedela/master
...
Add support for single row mode
2013-09-30 09:31:07 -07:00
Eugene Ware
4662d41972
bind Buffer variables as binary values
2013-09-19 01:50:42 +10:00
Rob Raux
bf419d2659
fix global variable leaks
2013-09-11 14:36:29 +00:00
Brian Carlson
1674359b57
Respect SSL setting from connection parameters
2013-09-09 11:50:20 -05:00
brianc
bfdea752b2
Respect PGSSLMODE for setting SSL connection
2013-09-05 16:51:16 -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
William Becker
3c6b106b86
fix trailing whitespace breaking jshint
2013-09-01 21:59:09 -05:00
William Becker
b7f8429ff7
handle early dates (< 100AD)
2013-09-01 21:59:09 -05:00
Brian Carlson
e744d05df7
Add ability to opt-in to int8 parsing
...
Switching the result of all COUNT operations to a string is
a pretty nasty breaking change, and the majority of us aren't
going to be hitting numbers larger than Number.MAX_VALUE
2013-08-29 00:04:27 -05:00
Brian Carlson
beeae35291
Fix js-hint error
2013-08-17 17:33:27 -05:00
Brian Carlson
c98125b065
Use on('data') for v0.8.x
2013-08-17 17:25:24 -05:00
Brian Carlson
5108161a47
Cleanup & tweak perf a bit
2013-08-17 14:21:19 -05:00
Brian Carlson
306f5dd493
Add comments
2013-08-07 15:35:07 -05:00
Brian Carlson
4cdd7a116b
Compile result parsing for a 60% speed increase
...
Tested against a 1000 row result set. Need to test against
smaller result sets & figure out a way to make this backwards compatible if possible
2013-08-07 15:33:57 -05:00
Brian Carlson
b6bca99489
Minor speed improvements
2013-08-07 12:41:38 -05:00
Brian Carlson
56b7c4168d
Create message in each parsing function
2013-08-07 12:20:51 -05:00
Brian Carlson
31318c02a2
Speed up JavaScript parser slightly
2013-08-07 11:57:43 -05:00
Brian C
a17f7fc381
Merge pull request #409 from rpedela/master
...
Fix build when escape functions are not supported in libpq
2013-08-01 07:26:55 -07:00
Brian Carlson
fb5520bb8a
Remove built-in binary int64 parser
2013-07-30 13:15:31 -05:00
rpedela
cf07a4f2b4
#403 Only use native escape functions if PG version >= 9.0.0. Otherwise use the JS functions.
2013-07-29 15:45:36 -06:00
Brian Carlson
910cc134c9
Make ref an optional dependency
...
The ref module adds a compile step even when using the pure-JavaScript client.
This makes the installation optional so if the install fails due to not having
a compiler around you can still use the JavaScript client.
closes #398
2013-07-23 10:10:41 -05:00
rpedela
ffe51c20f2
Add missing semicolons.
2013-07-15 09:13:48 -05:00
rpedela
876018e103
Add support for PQescapeLiteral and PQescapeIdentifier. Also add JS versions of the functions.
2013-07-15 09:13:48 -05:00
Aaron Boyd
0632c4eaf4
remove reference to pool when destroying
...
Leaving a reference to the pool means the
destroyed pool will get returned if you
later try to reconnect with the same
connection string.
2013-07-09 18:22:09 -07:00
Brian Carlson
145666c1b3
Support result rows as arrays
2013-07-08 17:45:06 -05:00
Brian Carlson
5462561e51
Cache result parser lookups
2013-07-08 09:32:53 -05:00
Brian Carlson
413eff72e5
Move row parsing into result object
2013-07-08 09:30:10 -05:00
Brian Carlson
3f96bbbc5c
Add field metadata to query result object
...
Refactored the way rows are built in the native bindings which should
result in a small performance improvement
2013-07-08 09:19:30 -05:00
Brian Carlson
05e9026aea
Remove tab character
2013-07-08 08:16:10 -05:00
Brian C
58b4f266ea
Merge pull request #386 from brianc/js-ssl
...
Fix long-standing hanging SSL connection but with JavaScript
2013-07-01 12:43:54 -07:00
Brian C
5806afc8a1
Merge pull request #276 from bryanburgers/connection-url-ssl
...
Add ssl query string to the connection string parser #275
2013-06-29 23:24:02 -07:00
bmc
44784fa2f3
Fix JavaScript SSL upgrade logic
...
I had accepted the pull request way back without proper test coverage.
I've added test coverage & fixed this long-standing bug.
2013-06-29 23:20:48 -07:00
Brian C
95da124744
Merge pull request #385 from memosanchez/pg-default-test-hostname
...
Add default value for database host to lib/defaults.js
2013-06-29 15:50:31 -07:00
Guillermo A. Sanchez
738c966112
Add default value for connection host.
...
Native binding connection tests will fail if the PGHOST environment variable is not set.
There already exists several defaul values for user, password and port. It would make sense to have a default host setting as well - localhost appears to be a reasonable default.
2013-06-29 14:46:45 -07:00
Hannes Hörl
e9cb2965e9
Bugfix: safe call of .hasOwnProperty(...)
2013-06-26 23:46:15 +02:00
Hannes Hörl
c126ba1c7c
Added NODE_PG_FORCE_NATIVE to force usage of libpg bindings (native client)
2013-06-26 22:32:07 +02:00
Brian C
42bae0c55e
Merge pull request #353 from sevastos/bigint-bulletproofing
...
Handle bigint as string to prevent precision loss
2013-06-18 19:21:43 -07:00
Dave
6fea79712c
Client encoding in defaults as well
2013-06-06 12:32:04 -07:00
Dave
6b4bc3945f
Uses val function instead
2013-06-06 12:24:12 -07:00
Dave
f658b31aed
Changing to client_encoding, adding test for creating a connection
2013-06-06 12:16:36 -07:00
Dave
d69070529c
Makes encoding an optional parameter
2013-06-06 12:06:52 -07:00
Brian Carlson
337d49dddb
Return field metadata on result object
...
Closes #209
Native implementation requires significant refactor and so I wont work on this
if/until there is an issue for it
2013-06-03 12:14:47 -05:00
sevastos
c2a93aafa5
Small improvements in parsers, additions to tests
2013-05-27 10:55:49 +03:00
sevastos
f827f56ed2
BigInt parsing bullet-proofing
2013-05-23 20:10:08 +03:00
Hebo
323a2f9f49
Fix client_encoding setting to support pg_bouncer when using libpq ( #270 )
2013-05-21 14:37:06 -07:00
Andrey Popp
4458e69285
call EventEmmiter constructor on native Connection
...
this allows to preserve an active domain on switches in libpq
2013-05-20 18:31:55 +04:00
bmc
10e6d85266
Add support for JSON data type
...
requires >= 9.2 of postgres
2013-04-22 10:18:17 -05:00
bmc
2ef1bbf8de
Parse minutes in timezone description
...
Minutes in timezones are separated with a colon from the hour.
This closes #309
2013-04-22 04:57:46 -05:00
Brian C
8a2e864b30
Merge pull request #238 from cdauth/master
...
Store timezone-less dates in local time instead of UTC
2013-04-22 02:17:05 -07:00
bmc
56a5903a02
Make throws in query error callback not break client
...
If you receive an error while running a query and in user's callback
they throw an exception it can disrupt the internal query queue
and prevent a client from ever cleaning up properly
2013-04-19 09:25:53 -05:00
bmc
9b1c4facc2
Make query callback exceptions not break client
...
If you throw an exception in a query callback the client will not pulse
its internal query queue and therefor will never process any
more queries or emit its own 'drain' event.
I don't find this to be an issue in production code since I restart
the process on exceptions, but it can break tests and cause things
to 'hang'. My crude benchmarks show no noticable impact in perf
from the try/catch/rethrow.
:q
2013-04-19 09:09:28 -05:00
brianc
3f5df0afa2
make tests pass on pg@8.4.9
2013-04-17 10:29:42 -05:00
za-creature
b6ef157e8e
Update connection-parameters.js
2013-04-11 23:35:21 +03:00