@@ -1103,6 +1103,14 @@ void DatabaseSync::Close(const FunctionCallbackInfo<Value>& args) {
1103
1103
db->connection_ = nullptr ;
1104
1104
}
1105
1105
1106
+ void DatabaseSync::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
1107
+ v8::TryCatch try_catch (args.GetIsolate ());
1108
+ Close (args);
1109
+ if (try_catch.HasCaught ()) {
1110
+ CHECK (try_catch.CanContinue ());
1111
+ }
1112
+ }
1113
+
1106
1114
void DatabaseSync::Prepare (const FunctionCallbackInfo<Value>& args) {
1107
1115
DatabaseSync* db;
1108
1116
ASSIGN_OR_RETURN_UNWRAP (&db, args.This ());
@@ -3015,6 +3023,7 @@ Local<FunctionTemplate> Session::GetConstructorTemplate(Environment* env) {
3015
3023
SetProtoMethod (
3016
3024
isolate, tmpl, " patchset" , Session::Changeset<sqlite3session_patchset>);
3017
3025
SetProtoMethod (isolate, tmpl, " close" , Session::Close);
3026
+ SetProtoDispose (isolate, tmpl, Session::Dispose);
3018
3027
env->set_sqlite_session_constructor_template (tmpl);
3019
3028
}
3020
3029
return tmpl;
@@ -3059,6 +3068,14 @@ void Session::Close(const FunctionCallbackInfo<Value>& args) {
3059
3068
session->Delete ();
3060
3069
}
3061
3070
3071
+ void Session::Dispose (const v8::FunctionCallbackInfo<v8::Value>& args) {
3072
+ v8::TryCatch try_catch (args.GetIsolate ());
3073
+ Close (args);
3074
+ if (try_catch.HasCaught ()) {
3075
+ CHECK (try_catch.CanContinue ());
3076
+ }
3077
+ }
3078
+
3062
3079
void Session::Delete () {
3063
3080
if (!database_ || !database_->connection_ || session_ == nullptr ) return ;
3064
3081
sqlite3session_delete (session_);
@@ -3094,6 +3111,7 @@ static void Initialize(Local<Object> target,
3094
3111
3095
3112
SetProtoMethod (isolate, db_tmpl, " open" , DatabaseSync::Open);
3096
3113
SetProtoMethod (isolate, db_tmpl, " close" , DatabaseSync::Close);
3114
+ SetProtoDispose (isolate, db_tmpl, DatabaseSync::Dispose);
3097
3115
SetProtoMethod (isolate, db_tmpl, " prepare" , DatabaseSync::Prepare);
3098
3116
SetProtoMethod (isolate, db_tmpl, " exec" , DatabaseSync::Exec);
3099
3117
SetProtoMethod (isolate, db_tmpl, " function" , DatabaseSync::CustomFunction);
@@ -3133,6 +3151,8 @@ static void Initialize(Local<Object> target,
3133
3151
target,
3134
3152
" StatementSync" ,
3135
3153
StatementSync::GetConstructorTemplate (env));
3154
+ SetConstructorFunction (
3155
+ context, target, " Session" , Session::GetConstructorTemplate (env));
3136
3156
3137
3157
target->Set (context, env->constants_string (), constants).Check ();
3138
3158
0 commit comments