diff --git a/package-lock.json b/package-lock.json index 16c9ce42..879ad17b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -64,9 +64,9 @@ } }, "@electron/get": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@electron/get/-/get-1.10.0.tgz", - "integrity": "sha512-hlueNXU51c3CwQjBw/i5fwt+VfQgSQVUTdicpCHkhEjNZaa4CXJ5W1GaxSwtLE2dvRmAHjpIjUMHTqJ53uojfg==", + "version": "1.12.2", + "resolved": "https://registry.npmjs.org/@electron/get/-/get-1.12.2.tgz", + "integrity": "sha512-vAuHUbfvBQpYTJ5wB7uVIDq5c/Ry0fiTBMs7lnEYAo/qXXppIVcWdfBr57u6eRnKdVso7KSiH6p/LbQAG6Izrg==", "dev": true, "requires": { "debug": "^4.1.1", @@ -155,9 +155,9 @@ "dev": true }, "@types/node": { - "version": "13.13.4", - "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.4.tgz", - "integrity": "sha512-x26ur3dSXgv5AwKS0lNfbjpCakGIduWU1DU91Zz58ONRWrIKGunmZBNv4P7N+e27sJkiGDsw/3fT4AtsqQBrBA==", + "version": "13.13.5", + "resolved": "https://registry.npmjs.org/@types/node/-/node-13.13.5.tgz", + "integrity": "sha512-3ySmiBYJPqgjiHA7oEaIo2Rzz0HrOZ7yrNO5HWyaE5q0lQ3BppDZ3N53Miz8bw2I7gh1/zir2MGVZBvpb1zq9g==", "dev": true }, "@types/sequelize": { @@ -1277,9 +1277,9 @@ } }, "electron": { - "version": "8.2.3", - "resolved": "https://registry.npmjs.org/electron/-/electron-8.2.3.tgz", - "integrity": "sha512-FJUp103c8yJBoAaj/QM/OBde57iJh95u1yGJBytMUXmLFSsx78LmNE03QN4XCODyzi76IEcasvUcK6scogRLbQ==", + "version": "8.2.5", + "resolved": "https://registry.npmjs.org/electron/-/electron-8.2.5.tgz", + "integrity": "sha512-LxSCUwmlfJtRwthd3ofpYaZ+1C2hQSW8Ep1DD9K3VbnDItO+kb3t1z35daJgAab78j54aOwo9gMxJtvU0Ftj6w==", "dev": true, "requires": { "@electron/get": "^1.0.1", @@ -1288,9 +1288,9 @@ }, "dependencies": { "@types/node": { - "version": "12.12.37", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.37.tgz", - "integrity": "sha512-4mXKoDptrXAwZErQHrLzpe0FN/0Wmf5JRniSVIdwUrtDf9wnmEV1teCNLBo/TwuXhkK/bVegoEn/wmb+x0AuPg==", + "version": "12.12.38", + "resolved": "https://registry.npmjs.org/@types/node/-/node-12.12.38.tgz", + "integrity": "sha512-75eLjX0pFuTcUXnnWmALMzzkYorjND0ezNEycaKesbUBg9eGZp4GHPuDmkRc4mQQvIpe29zrzATNRA6hkYqwmA==", "dev": true } } @@ -2001,9 +2001,9 @@ }, "dependencies": { "graceful-fs": { - "version": "4.2.3", - "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.3.tgz", - "integrity": "sha512-a30VEBm4PEdx1dRB7MFK7BejejvCvBronbLjht+sHuGYj8PHs7M/5Z+rt5lw551vZ7yfTCj4Vuyy3mSJytDWRQ==", + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", "dev": true } } diff --git a/package.json b/package.json index d90ebc9c..7e31a1ad 100644 --- a/package.json +++ b/package.json @@ -60,11 +60,11 @@ }, "devDependencies": { "@types/electron": "^1.4.31", - "@types/node": "^13.13.4", + "@types/node": "^13.13.5", "@types/sequelize": "^4.28.8", "asynquence": "^0.10.2", "asynquence-contrib": "^0.28.2", - "electron": "^8.2.3", + "electron": "^8.2.5", "minimist": "^1.2.5", "mocha": "^7.1.2", "node-gyp": "^4.0.0", diff --git a/src/BoundDatum.cpp b/src/BoundDatum.cpp index 6ae4763b..c791b561 100644 --- a/src/BoundDatum.cpp +++ b/src/BoundDatum.cpp @@ -428,7 +428,7 @@ namespace mssql const auto precision = min(1024, s->Length() + 1); s->WriteUtf8(fact.isolate, tmp, precision); const string narrow(tmp); - const auto wide = converter.from_bytes(narrow); + auto wide = converter.from_bytes(narrow); return wide; } @@ -595,8 +595,8 @@ namespace mssql const auto elem = MutateJS::get_array_elelemt_at_index(arr, i); if (!elem->IsNull()) { - const Local local; - const auto d = local->Value(); + const auto num = Local::Cast(elem); + const auto d = num->Value(); encode_numeric_struct(d, static_cast(param_size), digits, ns); param_size = ns.precision; digits = static_cast(ns.scale); @@ -1287,7 +1287,7 @@ namespace mssql Local pval; const nodeTypeFactory fact; - if (sql_type_s_maps_to_int32(p)) + if (sql_type_s_maps_to_int32(p) || sql_type_s_maps_to_boolean(p)) { pval = fact.new_int32(0); } @@ -1295,10 +1295,6 @@ namespace mssql { pval = fact.new_uint32(0); } - else if (sql_type_s_maps_to_boolean(p)) - { - pval = fact.new_int32(0); - } else if (sql_type_s_maps_to_numeric(p)) { pval = fact.new_number(0.0); @@ -1812,11 +1808,7 @@ namespace mssql err = static_cast("Invalid number parameter"); return false; } - else if (counts.numberCount > 0) - { - bind_double_array(pp); - } - else if (counts.int64Count > 0 && counts.int32Count > 0) + else if (counts.numberCount > 0 || counts.int64Count > 0 && counts.int32Count > 0) { bind_double_array(pp); } diff --git a/src/Connection.cpp b/src/Connection.cpp index 6d78a08d..63da727a 100644 --- a/src/Connection.cpp +++ b/src/Connection.cpp @@ -87,7 +87,7 @@ namespace mssql void Connection::close(const FunctionCallbackInfo& info) { const auto cb = info[0].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->close(cb); info.GetReturnValue().Set(ret); } @@ -95,7 +95,7 @@ namespace mssql void Connection::begin_transaction(const FunctionCallbackInfo& info) { const auto cb = info[0].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->begin_transaction(cb); info.GetReturnValue().Set(ret); } @@ -103,7 +103,7 @@ namespace mssql void Connection::commit(const FunctionCallbackInfo& info) { const auto cb = info[0].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->commit(cb); info.GetReturnValue().Set(ret); } @@ -111,7 +111,7 @@ namespace mssql void Connection::rollback(const FunctionCallbackInfo& info) { const auto cb = info[0].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->rollback(cb); info.GetReturnValue().Set(ret); } @@ -134,7 +134,7 @@ namespace mssql const auto params = info[2].As(); const auto callback = info[3].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->query(query_id, query_object, params, callback); info.GetReturnValue().Set(ret); } @@ -145,7 +145,7 @@ namespace mssql const auto query_object = info[1].As(); const auto callback = info[2].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->prepare(query_id, query_object, callback); info.GetReturnValue().Set(ret); } @@ -156,7 +156,7 @@ namespace mssql const auto params = info[1].As(); const auto callback = info[2].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->query_prepared(query_id, params, callback); info.GetReturnValue().Set(ret); } @@ -169,7 +169,7 @@ namespace mssql const auto params = info[2].As(); const auto callback = info[3].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->call_procedure(query_id, query_object, params, callback); info.GetReturnValue().Set(ret); } @@ -178,7 +178,7 @@ namespace mssql { const auto query_id = info[0].As(); const auto callback = info[1].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->unbind_parameters(query_id, callback); info.GetReturnValue().Set(ret); } @@ -187,7 +187,7 @@ namespace mssql { const auto query_id = info[0].As(); const auto callback = info[1].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->free_statement(query_id, callback); info.GetReturnValue().Set(ret); } @@ -197,7 +197,7 @@ namespace mssql const auto query_id = info[0].As(); const auto number_rows = info[1].As(); const auto cb = info[2].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->read_column(query_id, number_rows, cb); info.GetReturnValue().Set(ret); } @@ -206,7 +206,7 @@ namespace mssql { const auto query_id = info[0].As(); const auto callback = info[1].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->read_next_result(query_id, callback); info.GetReturnValue().Set(ret); } @@ -216,7 +216,7 @@ namespace mssql const auto connection_object = info[0].As(); const auto callback = info[1].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->open(connection_object, callback, info.This()); info.GetReturnValue().Set(ret); } @@ -225,7 +225,7 @@ namespace mssql { const auto query_id = info[0].As(); const auto callback = info[1].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const auto ret = connection->connectionBridge->cancel(query_id, callback); info.GetReturnValue().Set(ret); @@ -236,7 +236,7 @@ namespace mssql const auto query_id = info[0].As(); const auto v1 = info[1].As(); const auto callback = info[2].As(); - const auto connection = Unwrap(info.This()); + auto* const connection = Unwrap(info.This()); const nodeTypeFactory fact; const auto context = fact.isolate->GetCurrentContext(); const auto maybe = v1->Int32Value(context); diff --git a/src/MutateJS.cpp b/src/MutateJS.cpp index 37a4b9aa..a28e2f16 100644 --- a/src/MutateJS.cpp +++ b/src/MutateJS.cpp @@ -169,7 +169,7 @@ namespace mssql return val; } - Local MutateJS::get_array_elelemt_at_index(const Local &arr, const int index) + Local MutateJS::get_array_elelemt_at_index(const Local &arr, const unsigned int index) { const nodeTypeFactory fact; const auto context = fact.isolate->GetCurrentContext(); @@ -179,7 +179,7 @@ namespace mssql return elem; } - void MutateJS::set_array_elelemt_at_index(const Local& arr, const int index, const Local& value) + void MutateJS::set_array_elelemt_at_index(const Local& arr, const unsigned int index, const Local& value) { const nodeTypeFactory fact; const auto context = fact.isolate->GetCurrentContext(); diff --git a/src/MutateJS.h b/src/MutateJS.h index 7b3a25a1..6aa631be 100644 --- a/src/MutateJS.h +++ b/src/MutateJS.h @@ -14,8 +14,8 @@ namespace mssql static Local get_property_as_value(const Local& o, const char* v); static Local get_property_as_value(const Local& o, const Local& v); static void set_property_value(const Local& o, const Local& p, const Local& v); - static Local get_array_elelemt_at_index(const Local & arr, const int index); - static void set_array_elelemt_at_index(const Local& arr, const int index, const Local & value); + static Local get_array_elelemt_at_index(const Local & arr, const unsigned int index); + static void set_array_elelemt_at_index(const Local& arr, const unsigned int index, const Local & value); static int32_t getint32(Local query_object, const char* v); static int64_t getint64(Local query_object, const char* v); static int64_t getint64(Local l); diff --git a/unit.tests/tvp.js b/unit.tests/tvp.js index c64c72a1..08eaf231 100644 --- a/unit.tests/tvp.js +++ b/unit.tests/tvp.js @@ -64,12 +64,13 @@ END` \tdescription varchar(max), \tusername nvarchar(30), \tage int, -\tsalary real +\tsalary real, +\tcode numeric(18,0) )` const dropTypeSql = `IF TYPE_ID(N'${tableTypeName}') IS not NULL drop type ${tableTypeName}` - const createTypeSql = `CREATE TYPE ${tableTypeName} AS TABLE (description varchar(max), username nvarchar(30), age int, salary real)` + const createTypeSql = `CREATE TYPE ${tableTypeName} AS TABLE (description varchar(max), username nvarchar(30), age int, salary real, code numeric(18,0))` const insertProcedureSql = `create PROCEDURE ${insertProcedureTypeName} @tvp ${tableTypeName} READONLY @@ -81,13 +82,15 @@ BEGIN [description], [username], [age], - [salary] + [salary], + [code] ) SELECT [description], [username], [age], - [salary] + [salary], + [code] n FROM @tvp tvp END` @@ -146,7 +149,7 @@ END` theConnection.getUserTypeTable(tableTypeName, (err, t) => { assert.ifError(err) table = t - assert(table.columns.length === 4) + assert(table.columns.length === 5) asyncDone() }) } @@ -168,13 +171,15 @@ END` description: longString, username: 'santa', age: 1000, - salary: 0 + salary: 0, + code: 123456789012345 }, { description: 'an entry', username: 'md', age: 28, - salary: 100000 + salary: 100000, + code: 98765432109876 } ] } @@ -186,13 +191,15 @@ END` description: longString, username: 'santa', age: 1000, - salary: 0 + salary: 0, + code: 123456789012345 }, { description: 'can compound â€', username: 'md', age: 28, - salary: 100000 + salary: 100000, + code: 98765432109876 } ] }