Commit 9f039e82 by Konstantin Käfer

also check Statement objects for IsConstructCall

refs #29
parent 16ac5dc7
......@@ -82,6 +82,12 @@ template <class T> void Statement::Error(T* baton) {
Handle<Value> Statement::New(const Arguments& args) {
HandleScope scope;
if (!args.IsConstructCall()) {
return ThrowException(Exception::TypeError(
String::New("Use the new operator to create new Statement objects"))
);
}
int length = args.Length();
if (length <= 0 || !Database::HasInstance(args[0])) {
......
......@@ -5,6 +5,10 @@ exports['test Database() without new'] = function(beforeExit) {
assert.throws(function() {
sqlite3.Database(':memory:');
}, (/Use the new operator to create new Database objects/));
assert.throws(function() {
sqlite3.Statement();
}, (/Use the new operator to create new Statement objects/));
};
exports['test Database#get prepare fail'] = function(beforeExit) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment