@@ -1002,6 +1002,14 @@ void DatabaseSync::Close(const FunctionCallbackInfo<Value>& args) {
10021002 db->connection_ = nullptr ;
10031003}
10041004
1005+ void DatabaseSync::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
1006+ v8::TryCatch try_catch (args.GetIsolate ());
1007+ Close (args);
1008+ if (try_catch.HasCaught ()) {
1009+ CHECK (try_catch.CanContinue ());
1010+ }
1011+ }
1012+
10051013void DatabaseSync::Prepare (const FunctionCallbackInfo<Value>& args) {
10061014 DatabaseSync* db;
10071015 ASSIGN_OR_RETURN_UNWRAP (&db, args.This ());
@@ -2574,6 +2582,7 @@ Local<FunctionTemplate> Session::GetConstructorTemplate(Environment* env) {
25742582 SetProtoMethod (
25752583 isolate, tmpl, " patchset" , Session::Changeset<sqlite3session_patchset>);
25762584 SetProtoMethod (isolate, tmpl, " close" , Session::Close);
2585+ SetProtoDispose (isolate, tmpl, Session::Dispose);
25772586 env->set_sqlite_session_constructor_template (tmpl);
25782587 }
25792588 return tmpl;
@@ -2618,6 +2627,14 @@ void Session::Close(const FunctionCallbackInfo<Value>& args) {
26182627 session->Delete ();
26192628}
26202629
2630+ void Session::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
2631+ v8::TryCatch try_catch (args.GetIsolate ());
2632+ Close (args);
2633+ if (try_catch.HasCaught ()) {
2634+ CHECK (try_catch.CanContinue ());
2635+ }
2636+ }
2637+
26212638void Session::Delete () {
26222639 if (!database_ || !database_->connection_ || session_ == nullptr ) return ;
26232640 sqlite3session_delete (session_);
@@ -2653,6 +2670,7 @@ static void Initialize(Local<Object> target,
26532670
26542671 SetProtoMethod (isolate, db_tmpl, " open" , DatabaseSync::Open);
26552672 SetProtoMethod (isolate, db_tmpl, " close" , DatabaseSync::Close);
2673+ SetProtoDispose (isolate, db_tmpl, DatabaseSync::Dispose);
26562674 SetProtoMethod (isolate, db_tmpl, " prepare" , DatabaseSync::Prepare);
26572675 SetProtoMethod (isolate, db_tmpl, " exec" , DatabaseSync::Exec);
26582676 SetProtoMethod (isolate, db_tmpl, " function" , DatabaseSync::CustomFunction);
@@ -2683,6 +2701,8 @@ static void Initialize(Local<Object> target,
26832701 target,
26842702 " StatementSync" ,
26852703 StatementSync::GetConstructorTemplate (env));
2704+ SetConstructorFunction (
2705+ context, target, " Session" , Session::GetConstructorTemplate (env));
26862706
26872707 target->Set (context, env->constants_string (), constants).Check ();
26882708
0 commit comments