Skip to content

Commit 16ac5dc

Browse files
committed
check for IsConstructCall
refs TryGhost#29
1 parent 4c87119 commit 16ac5dc

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

src/database.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ void Database::Schedule(EIO_Callback callback, Baton* baton, bool exclusive) {
105105
Handle<Value> Database::New(const Arguments& args) {
106106
HandleScope scope;
107107

108-
if (!Database::HasInstance(args.This())) {
108+
if (!args.IsConstructCall()) {
109109
return ThrowException(Exception::TypeError(
110110
String::New("Use the new operator to create new Database objects"))
111111
);

test/database_fail.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
var sqlite3 = require('sqlite3');
22
var assert = require('assert');
33

4+
exports['test Database() without new'] = function(beforeExit) {
5+
assert.throws(function() {
6+
sqlite3.Database(':memory:');
7+
}, (/Use the new operator to create new Database objects/));
8+
};
9+
410
exports['test Database#get prepare fail'] = function(beforeExit) {
511
var db = new sqlite3.Database(':memory:');
612

0 commit comments

Comments
 (0)