diff --git a/src/database.cpp b/src/database.cpp index 819ff8fb..a96027f8 100644 --- a/src/database.cpp +++ b/src/database.cpp @@ -45,7 +45,8 @@ struct OpenTask : public Task { try { duckdb_config.SetOptionByName(key, duckdb::Value(val)); } catch (std::exception &e) { - throw Napi::TypeError::New(env, "Failed to set configuration option " + key + ": " + e.what()); + duckdb::ErrorData error(e); + throw Napi::TypeError::New(env, "Failed to set configuration option " + key + ": " + error.Message()); } } } diff --git a/src/duckdb/src/common/local_file_system.cpp b/src/duckdb/src/common/local_file_system.cpp index b1d29251..75ada199 100644 --- a/src/duckdb/src/common/local_file_system.cpp +++ b/src/duckdb/src/common/local_file_system.cpp @@ -50,6 +50,7 @@ extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory(PULONGLONG) #endif // NOLINT #elif defined(_WIN32) #include +#pragma comment(lib, "rstrtmgr.lib") #endif namespace duckdb { diff --git a/src/statement.cpp b/src/statement.cpp index 01420d71..eb9de676 100644 --- a/src/statement.cpp +++ b/src/statement.cpp @@ -161,15 +161,25 @@ static Napi::Value convert_col_val(Napi::Env &env, duckdb::Value dval, duckdb::L case duckdb::LogicalTypeId::DOUBLE: { value = Napi::Number::New(env, duckdb::DoubleValue::Get(dval)); } break; + case duckdb::LogicalTypeId::UHUGEINT: { + auto val = duckdb::UhugeIntValue::Get(dval); + const uint64_t words[] = {val.lower, val.upper}; + value = Napi::BigInt::New(env, false, 2, words); + } break; case duckdb::LogicalTypeId::HUGEINT: { auto val = duckdb::HugeIntValue::Get(dval); - auto negative = val.upper < 0; - if (negative) { - duckdb::Hugeint::NegateInPlace(val); // remove signing bit + const uint64_t words_min[] = {0, 1ull<<63}; + if (val == duckdb::NumericLimits::Minimum()) { + value = Napi::BigInt::New(env, true, 2, words_min); + } else { + auto negative = val.upper < 0; + if (negative) { + duckdb::Hugeint::NegateInPlace(val); // remove signing bit + } + D_ASSERT(val.upper >= 0); + const uint64_t words[] = {val.lower, static_cast(val.upper)}; + value = Napi::BigInt::New(env, negative, 2, words); } - D_ASSERT(val.upper >= 0); - const uint64_t words[] = {val.lower, static_cast(val.upper)}; - value = Napi::BigInt::New(env, negative, 2, words); } break; case duckdb::LogicalTypeId::DECIMAL: { value = Napi::Number::New(env, dval.GetValue()); diff --git a/test/columns.test.ts b/test/columns.test.ts index 52bfdb3d..3073b3de 100644 --- a/test/columns.test.ts +++ b/test/columns.test.ts @@ -12,7 +12,7 @@ describe('Column Types', function() { let cols = stmt.columns(); - assert.equal(cols.length, 42); + assert.equal(cols.length, 43); var expected = [ { name: 'bool', type: { id: 'BOOLEAN', sql_type: 'BOOLEAN' } }, @@ -21,6 +21,7 @@ describe('Column Types', function() { { name: 'int', type: { id: 'INTEGER', sql_type: 'INTEGER' } }, { name: 'bigint', type: { id: 'BIGINT', sql_type: 'BIGINT' } }, { name: 'hugeint', type: { id: 'HUGEINT', sql_type: 'HUGEINT' } }, + { name: 'uhugeint', type: { id: 'UHUGEINT', sql_type: 'UHUGEINT' } }, { name: 'utinyint', type: { id: 'UTINYINT', sql_type: 'UTINYINT' } }, { name: 'usmallint', type: { id: 'USMALLINT', sql_type: 'USMALLINT' } }, { name: 'uint', type: { id: 'UINTEGER', sql_type: 'UINTEGER' } }, diff --git a/test/test_all_types.test.ts b/test/test_all_types.test.ts index f13a8831..db0ea5cd 100644 --- a/test/test_all_types.test.ts +++ b/test/test_all_types.test.ts @@ -48,8 +48,13 @@ const correct_answer_map: Record = { int: [-2147483648, 2147483647, null], bigint: [BigInt("-9223372036854775808"), BigInt("9223372036854775807"), null], + uhugeint: [ + BigInt("0"), + BigInt("340282366920938463463374607431768211455"), + null, + ], hugeint: [ - BigInt("-170141183460469231731687303715884105727"), + BigInt("-170141183460469231731687303715884105728"), BigInt("170141183460469231731687303715884105727"), null, ], @@ -60,7 +65,7 @@ const correct_answer_map: Record = { uint: [0, 4294967295, null], ubigint: [BigInt(0), BigInt("18446744073709551615"), null], - time: ["00:00:00", "23:59:59.999999", null], + time: ["00:00:00", "24:00:00", null], float: [-3.4028234663852886e38, 3.4028234663852886e38, null], double: [-1.7976931348623157e308, 1.7976931348623157e308, null], @@ -74,7 +79,7 @@ const correct_answer_map: Record = { null, ], uuid: [ - "00000000-0000-0000-0000-000000000001", + "00000000-0000-0000-0000-000000000000", "ffffffff-ffff-ffff-ffff-ffffffffffff", null, ], @@ -161,7 +166,7 @@ const correct_answer_map: Record = { map: ["{}", "{key1=🦆🦆🦆🦆🦆🦆, key2=goose}", null], union: ["Frank", "5", null], - time_tz: ["00:00:00-1559", "23:59:59.999999+1559", null], + time_tz: ["00:00:00+15:59:59", "24:00:00-15:59:59", null], interval: [ timedelta({ days: 0,