Skip to content

Commit 9f955c4

Browse files
abenhamdinebrianc
authored andcommitted
Add details about differences between js and native bindings (brianc#1096)
1 parent 4e77464 commit 9f955c4

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

README.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,17 @@ var Pool = pg.Pool // good! a pool bound to the native client
139139
var Client = pg.Client // good! this client uses libpq bindings
140140
```
141141

142-
node-postgres abstracts over the pg-native module to provide exactly the same interface as the pure JavaScript version. Care has been taken to keep the number of api differences between the two modules to a minimum; however, it is recommended you use either the pure JavaScript or native bindings in both development and production and don't mix & match them in the same process - it can get confusing!
142+
#### API differences
143+
144+
node-postgres abstracts over the pg-native module to provide the same interface as the pure JavaScript version. Care has been taken to keep the number of api differences between the two modules to a minimum.
145+
However, currently some differences remain, especially :
146+
* the error object in pg-native is different : notably, the information about the postgres error code is not present in field `code` but in the field `sqlState` , and the name of a few other fields is different (see https://github.com/brianc/node-postgres/issues/938, https://github.com/brianc/node-postgres/issues/972).
147+
So for example, if you rely on error.code in your application, your will have to adapt your code to work with native bindings.
148+
* the notification object has a few less properties (see https://github.com/brianc/node-postgres/issues/1045)
149+
* column objects have less properties (see https://github.com/brianc/node-postgres/issues/988)
150+
* the modules https://github.com/brianc/node-pg-copy-streams and https://github.com/brianc/node-pg-query-stream do not work with native bindings (you will have to require 'pg' to use them).
151+
152+
Thus, it is recommended you use either the pure JavaScript or native bindings in both development and production and don't mix & match them in the same process - it can get confusing!
143153

144154
## Features
145155

0 commit comments

Comments
 (0)