forked from brianc/node-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Requiring native bindings polutes 'global' (brianc#984)
There was some nasty global-ish variable reference updating happening when the native module 'initializes' after its require with `require('pg').native` This fixes the issue by making sure both `require('pg')` and `require('pg').native` each initialize their own context in isolation and no weird global-ish references are used & subsequently stomped on.
- Loading branch information
Showing
5 changed files
with
121 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
var helper = require(__dirname + '/../test-helper'); | ||
|
||
//native bindings are only installed for native tests | ||
if(!helper.args.native) { | ||
return; | ||
} | ||
|
||
var assert = require('assert') | ||
var pg = require('../../../lib') | ||
var native = require('../../../lib').native | ||
|
||
var JsClient = require('../../../lib/client') | ||
var NativeClient = require('../../../lib/native') | ||
|
||
assert(pg.Client === JsClient); | ||
assert(native.Client === NativeClient); | ||
|
||
pg.connect(function(err, client, done) { | ||
assert(client instanceof JsClient); | ||
client.end(); | ||
|
||
native.connect(function(err, client, done) { | ||
assert(client instanceof NativeClient); | ||
client.end(); | ||
}); | ||
}); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters