Skip to content

Commit 723de4c

Browse files
refackkewde
authored andcommitted
make compatible with V8 7.1 (TryGhost#1093)
* make compatible with V8 7.1 * Remove use of two argument Concat * fixup! bump nan
1 parent e173ebc commit 723de4c

File tree

4 files changed

+16
-19
lines changed

4 files changed

+16
-19
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
"url": "git://github.com/mapbox/node-sqlite3.git"
3838
},
3939
"dependencies": {
40-
"nan": "~2.10.0",
40+
"nan": "^2.12.1",
4141
"node-pre-gyp": "^0.11.0",
4242
"request": "^2.87.0"
4343
},

src/database.cc

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ void Database::Process() {
3737
Nan::HandleScope scope;
3838

3939
if (!open && locked && !queue.empty()) {
40-
EXCEPTION(Nan::New("Database handle is closed").ToLocalChecked(), SQLITE_MISUSE, exception);
40+
EXCEPTION("Database handle is closed", SQLITE_MISUSE, exception);
4141
Local<Value> argv[] = { exception };
4242
bool called = false;
4343

@@ -85,7 +85,7 @@ void Database::Schedule(Work_Callback callback, Baton* baton, bool exclusive) {
8585
Nan::HandleScope scope;
8686

8787
if (!open && locked) {
88-
EXCEPTION(Nan::New("Database is closed").ToLocalChecked(), SQLITE_MISUSE, exception);
88+
EXCEPTION("Database is closed", SQLITE_MISUSE, exception);
8989
Local<Function> cb = Nan::New(baton->callback);
9090
if (!cb.IsEmpty() && cb->IsFunction()) {
9191
Local<Value> argv[] = { exception };
@@ -176,7 +176,7 @@ void Database::Work_AfterOpen(uv_work_t* req) {
176176

177177
Local<Value> argv[1];
178178
if (baton->status != SQLITE_OK) {
179-
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
179+
EXCEPTION(baton->message, baton->status, exception);
180180
argv[0] = exception;
181181
}
182182
else {
@@ -256,7 +256,7 @@ void Database::Work_AfterClose(uv_work_t* req) {
256256

257257
Local<Value> argv[1];
258258
if (baton->status != SQLITE_OK) {
259-
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
259+
EXCEPTION(baton->message, baton->status, exception);
260260
argv[0] = exception;
261261
}
262262
else {
@@ -346,6 +346,9 @@ NAN_METHOD(Database::Configure) {
346346
}
347347
else {
348348
return Nan::ThrowError(Exception::Error(String::Concat(
349+
#if V8_MAJOR_VERSION > 6
350+
info.GetIsolate(),
351+
#endif
349352
Nan::To<String>(info[0]).ToLocalChecked(),
350353
Nan::New(" is not a valid configuration option").ToLocalChecked()
351354
)));
@@ -554,7 +557,7 @@ void Database::Work_AfterExec(uv_work_t* req) {
554557
Local<Function> cb = Nan::New(baton->callback);
555558

556559
if (baton->status != SQLITE_OK) {
557-
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
560+
EXCEPTION(baton->message, baton->status, exception);
558561

559562
if (!cb.IsEmpty() && cb->IsFunction()) {
560563
Local<Value> argv[] = { exception };
@@ -656,7 +659,7 @@ void Database::Work_AfterLoadExtension(uv_work_t* req) {
656659
Local<Function> cb = Nan::New(baton->callback);
657660

658661
if (baton->status != SQLITE_OK) {
659-
EXCEPTION(Nan::New(baton->message.c_str()).ToLocalChecked(), baton->status, exception);
662+
EXCEPTION(baton->message, baton->status, exception);
660663

661664
if (!cb.IsEmpty() && cb->IsFunction()) {
662665
Local<Value> argv[] = { exception };

src/macros.h

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,15 @@ const char* sqlite_authorizer_string(int type);
8383
Nan::New(property).ToLocalChecked()).ToLocalChecked()).FromJust();
8484

8585
#define EXCEPTION(msg, errno, name) \
86-
Local<Value> name = Exception::Error( \
87-
String::Concat( \
88-
String::Concat( \
89-
Nan::New(sqlite_code_string(errno)).ToLocalChecked(), \
90-
Nan::New(": ").ToLocalChecked() \
91-
), \
92-
(msg) \
93-
) \
94-
); \
86+
Local<Value> name = Exception::Error(Nan::New( \
87+
std::string(sqlite_code_string(errno)) + \
88+
std::string(": ") + std::string(msg) \
89+
).ToLocalChecked()); \
9590
Local<Object> name ##_obj = name.As<Object>(); \
9691
Nan::Set(name ##_obj, Nan::New("errno").ToLocalChecked(), Nan::New(errno));\
9792
Nan::Set(name ##_obj, Nan::New("code").ToLocalChecked(), \
9893
Nan::New(sqlite_code_string(errno)).ToLocalChecked());
9994

100-
10195
#define EMIT_EVENT(obj, argc, argv) \
10296
TRY_CATCH_CALL((obj), \
10397
Nan::Get(obj, \

src/statement.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ template <class T> void Statement::Error(T* baton) {
6565
Statement* stmt = baton->stmt;
6666
// Fail hard on logic errors.
6767
assert(stmt->status != 0);
68-
EXCEPTION(Nan::New(stmt->message.c_str()).ToLocalChecked(), stmt->status, exception);
68+
EXCEPTION(stmt->message, stmt->status, exception);
6969

7070
Local<Function> cb = Nan::New(baton->callback);
7171

@@ -857,7 +857,7 @@ void Statement::CleanQueue() {
857857
if (prepared && !queue.empty()) {
858858
// This statement has already been prepared and is now finalized.
859859
// Fire error for all remaining items in the queue.
860-
EXCEPTION(Nan::New<String>("Statement is already finalized").ToLocalChecked(), SQLITE_MISUSE, exception);
860+
EXCEPTION("Statement is already finalized", SQLITE_MISUSE, exception);
861861
Local<Value> argv[] = { exception };
862862
bool called = false;
863863

0 commit comments

Comments
 (0)