@@ -1000,6 +1000,14 @@ void DatabaseSync::Close(const FunctionCallbackInfo<Value>& args) {
10001000  db->connection_  = nullptr ;
10011001}
10021002
1003+ void  DatabaseSync::Dispose (const  v8::FunctionCallbackInfo<v8::Value>& args) {
1004+   v8::TryCatch try_catch (args.GetIsolate ());
1005+   Close (args);
1006+   if  (try_catch.HasCaught ()) {
1007+     CHECK (try_catch.CanContinue ());
1008+   }
1009+ }
1010+ 
10031011void  DatabaseSync::Prepare (const  FunctionCallbackInfo<Value>& args) {
10041012  DatabaseSync* db;
10051013  ASSIGN_OR_RETURN_UNWRAP (&db, args.This ());
@@ -2572,6 +2580,7 @@ Local<FunctionTemplate> Session::GetConstructorTemplate(Environment* env) {
25722580    SetProtoMethod (
25732581        isolate, tmpl, " patchset"  , Session::Changeset<sqlite3session_patchset>);
25742582    SetProtoMethod (isolate, tmpl, " close"  , Session::Close);
2583+     SetProtoDispose (isolate, tmpl, Session::Dispose);
25752584    env->set_sqlite_session_constructor_template (tmpl);
25762585  }
25772586  return  tmpl;
@@ -2616,6 +2625,14 @@ void Session::Close(const FunctionCallbackInfo<Value>& args) {
26162625  session->Delete ();
26172626}
26182627
2628+ void  Session::Dispose (const  v8::FunctionCallbackInfo<v8::Value>& args) {
2629+   v8::TryCatch try_catch (args.GetIsolate ());
2630+   Close (args);
2631+   if  (try_catch.HasCaught ()) {
2632+     CHECK (try_catch.CanContinue ());
2633+   }
2634+ }
2635+ 
26192636void  Session::Delete () {
26202637  if  (!database_ || !database_->connection_  || session_ == nullptr ) return ;
26212638  sqlite3session_delete (session_);
@@ -2651,6 +2668,7 @@ static void Initialize(Local<Object> target,
26512668
26522669  SetProtoMethod (isolate, db_tmpl, " open"  , DatabaseSync::Open);
26532670  SetProtoMethod (isolate, db_tmpl, " close"  , DatabaseSync::Close);
2671+   SetProtoDispose (isolate, db_tmpl, DatabaseSync::Dispose);
26542672  SetProtoMethod (isolate, db_tmpl, " prepare"  , DatabaseSync::Prepare);
26552673  SetProtoMethod (isolate, db_tmpl, " exec"  , DatabaseSync::Exec);
26562674  SetProtoMethod (isolate, db_tmpl, " function"  , DatabaseSync::CustomFunction);
@@ -2681,6 +2699,8 @@ static void Initialize(Local<Object> target,
26812699                         target,
26822700                         " StatementSync"  ,
26832701                         StatementSync::GetConstructorTemplate (env));
2702+   SetConstructorFunction (
2703+       context, target, " Session"  , Session::GetConstructorTemplate (env));
26842704
26852705  target->Set (context, env->constants_string (), constants).Check ();
26862706
0 commit comments