Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/duckdb/src/common/local_file_system.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory(PULONGLONG)
#endif // NOLINT
#elif defined(_WIN32)
#include <RestartManager.h>
#pragma comment(lib, "rstrtmgr.lib")
#endif

namespace duckdb {
Expand Down
22 changes: 16 additions & 6 deletions src/statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<duckdb::hugeint_t>::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<uint64_t>(val.upper)};
value = Napi::BigInt::New(env, negative, 2, words);
}
D_ASSERT(val.upper >= 0);
const uint64_t words[] = {val.lower, static_cast<uint64_t>(val.upper)};
value = Napi::BigInt::New(env, negative, 2, words);
} break;
case duckdb::LogicalTypeId::DECIMAL: {
value = Napi::Number::New(env, dval.GetValue<double>());
Expand Down
3 changes: 2 additions & 1 deletion test/columns.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' } },
Expand All @@ -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' } },
Expand Down
13 changes: 9 additions & 4 deletions test/test_all_types.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,13 @@ const correct_answer_map: Record<string, any[]> = {
int: [-2147483648, 2147483647, null],
bigint: [BigInt("-9223372036854775808"), BigInt("9223372036854775807"), null],

uhugeint: [
BigInt("0"),
BigInt("340282366920938463463374607431768211455"),
null,
],
hugeint: [
BigInt("-170141183460469231731687303715884105727"),
BigInt("-170141183460469231731687303715884105728"),
BigInt("170141183460469231731687303715884105727"),
null,
],
Expand All @@ -60,7 +65,7 @@ const correct_answer_map: Record<string, any[]> = {
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],
Expand All @@ -74,7 +79,7 @@ const correct_answer_map: Record<string, any[]> = {
null,
],
uuid: [
"00000000-0000-0000-0000-000000000001",
"00000000-0000-0000-0000-000000000000",
"ffffffff-ffff-ffff-ffff-ffffffffffff",
null,
],
Expand Down Expand Up @@ -161,7 +166,7 @@ const correct_answer_map: Record<string, any[]> = {
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,
Expand Down