Skip to content

Mark the native property as non-enumerable. Closes #945 #952

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,12 @@ if(typeof process.env.NODE_PG_FORCE_NATIVE != 'undefined') {
module.exports = new PG(Client);

//lazy require native module...the native module may not have installed
module.exports.__defineGetter__("native", function() {
delete module.exports.native;
module.exports.native = new PG(require('./native'));
return module.exports.native;
Object.defineProperty(module.exports, 'native', {
get: function () {
delete module.exports._native;
module.exports._native = new PG(require('./native'));
return module.exports._native;
},
enumerable: false
});
}
7 changes: 7 additions & 0 deletions test/unit/client/native-property-tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
var helper = require(__dirname + "/test-helper");
var client = require(__dirname + "/../../../lib");

test('native property is non-enumerable', function() {
assert.equal(Object.keys(client).indexOf('native'), -1);
});