@@ -1080,6 +1080,14 @@ void DatabaseSync::Close(const FunctionCallbackInfo<Value>& args) {
10801080 db->connection_ = nullptr ;
10811081}
10821082
1083+ void DatabaseSync::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
1084+ v8::TryCatch try_catch (args.GetIsolate ());
1085+ Close (args);
1086+ if (try_catch.HasCaught ()) {
1087+ CHECK (try_catch.CanContinue ());
1088+ }
1089+ }
1090+
10831091void DatabaseSync::Prepare (const FunctionCallbackInfo<Value>& args) {
10841092 DatabaseSync* db;
10851093 ASSIGN_OR_RETURN_UNWRAP (&db, args.This ());
@@ -2629,6 +2637,7 @@ Local<FunctionTemplate> Session::GetConstructorTemplate(Environment* env) {
26292637 SetProtoMethod (
26302638 isolate, tmpl, " patchset" , Session::Changeset<sqlite3session_patchset>);
26312639 SetProtoMethod (isolate, tmpl, " close" , Session::Close);
2640+ SetProtoDispose (isolate, tmpl, Session::Dispose);
26322641 env->set_sqlite_session_constructor_template (tmpl);
26332642 }
26342643 return tmpl;
@@ -2673,6 +2682,14 @@ void Session::Close(const FunctionCallbackInfo<Value>& args) {
26732682 session->Delete ();
26742683}
26752684
2685+ void Session::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
2686+ v8::TryCatch try_catch (args.GetIsolate ());
2687+ Close (args);
2688+ if (try_catch.HasCaught ()) {
2689+ CHECK (try_catch.CanContinue ());
2690+ }
2691+ }
2692+
26762693void Session::Delete () {
26772694 if (!database_ || !database_->connection_ || session_ == nullptr ) return ;
26782695 sqlite3session_delete (session_);
@@ -2708,6 +2725,7 @@ static void Initialize(Local<Object> target,
27082725
27092726 SetProtoMethod (isolate, db_tmpl, " open" , DatabaseSync::Open);
27102727 SetProtoMethod (isolate, db_tmpl, " close" , DatabaseSync::Close);
2728+ SetProtoDispose (isolate, db_tmpl, DatabaseSync::Dispose);
27112729 SetProtoMethod (isolate, db_tmpl, " prepare" , DatabaseSync::Prepare);
27122730 SetProtoMethod (isolate, db_tmpl, " exec" , DatabaseSync::Exec);
27132731 SetProtoMethod (isolate, db_tmpl, " function" , DatabaseSync::CustomFunction);
@@ -2745,6 +2763,8 @@ static void Initialize(Local<Object> target,
27452763 target,
27462764 " StatementSync" ,
27472765 StatementSync::GetConstructorTemplate (env));
2766+ SetConstructorFunction (
2767+ context, target, " Session" , Session::GetConstructorTemplate (env));
27482768
27492769 target->Set (context, env->constants_string (), constants).Check ();
27502770
0 commit comments