@@ -1005,6 +1005,14 @@ void DatabaseSync::Close(const FunctionCallbackInfo<Value>& args) {
10051005 db->connection_ = nullptr ;
10061006}
10071007
1008+ void DatabaseSync::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
1009+ v8::TryCatch try_catch (args.GetIsolate ());
1010+ Close (args);
1011+ if (try_catch.HasCaught ()) {
1012+ CHECK (try_catch.CanContinue ());
1013+ }
1014+ }
1015+
10081016void DatabaseSync::Prepare (const FunctionCallbackInfo<Value>& args) {
10091017 DatabaseSync* db;
10101018 ASSIGN_OR_RETURN_UNWRAP (&db, args.This ());
@@ -2577,6 +2585,7 @@ Local<FunctionTemplate> Session::GetConstructorTemplate(Environment* env) {
25772585 SetProtoMethod (
25782586 isolate, tmpl, " patchset" , Session::Changeset<sqlite3session_patchset>);
25792587 SetProtoMethod (isolate, tmpl, " close" , Session::Close);
2588+ SetProtoDispose (isolate, tmpl, Session::Dispose);
25802589 env->set_sqlite_session_constructor_template (tmpl);
25812590 }
25822591 return tmpl;
@@ -2621,6 +2630,14 @@ void Session::Close(const FunctionCallbackInfo<Value>& args) {
26212630 session->Delete ();
26222631}
26232632
2633+ void Session::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
2634+ v8::TryCatch try_catch (args.GetIsolate ());
2635+ Close (args);
2636+ if (try_catch.HasCaught ()) {
2637+ CHECK (try_catch.CanContinue ());
2638+ }
2639+ }
2640+
26242641void Session::Delete () {
26252642 if (!database_ || !database_->connection_ || session_ == nullptr ) return ;
26262643 sqlite3session_delete (session_);
@@ -2656,6 +2673,7 @@ static void Initialize(Local<Object> target,
26562673
26572674 SetProtoMethod (isolate, db_tmpl, " open" , DatabaseSync::Open);
26582675 SetProtoMethod (isolate, db_tmpl, " close" , DatabaseSync::Close);
2676+ SetProtoDispose (isolate, db_tmpl, DatabaseSync::Dispose);
26592677 SetProtoMethod (isolate, db_tmpl, " prepare" , DatabaseSync::Prepare);
26602678 SetProtoMethod (isolate, db_tmpl, " exec" , DatabaseSync::Exec);
26612679 SetProtoMethod (isolate, db_tmpl, " function" , DatabaseSync::CustomFunction);
@@ -2686,6 +2704,8 @@ static void Initialize(Local<Object> target,
26862704 target,
26872705 " StatementSync" ,
26882706 StatementSync::GetConstructorTemplate (env));
2707+ SetConstructorFunction (
2708+ context, target, " Session" , Session::GetConstructorTemplate (env));
26892709
26902710 target->Set (context, env->constants_string (), constants).Check ();
26912711
0 commit comments