Skip to content

Commit d569cf7

Browse files
authored
Merge pull request #48 from carlopi/fix_0100
Fixes for 0.10.0
2 parents 03a403d + 4b585ef commit d569cf7

File tree

5 files changed

+30
-12
lines changed

5 files changed

+30
-12
lines changed

src/database.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ struct OpenTask : public Task {
4545
try {
4646
duckdb_config.SetOptionByName(key, duckdb::Value(val));
4747
} catch (std::exception &e) {
48-
throw Napi::TypeError::New(env, "Failed to set configuration option " + key + ": " + e.what());
48+
duckdb::ErrorData error(e);
49+
throw Napi::TypeError::New(env, "Failed to set configuration option " + key + ": " + error.Message());
4950
}
5051
}
5152
}

src/duckdb/src/common/local_file_system.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ extern "C" WINBASEAPI BOOL WINAPI GetPhysicallyInstalledSystemMemory(PULONGLONG)
5050
#endif // NOLINT
5151
#elif defined(_WIN32)
5252
#include <RestartManager.h>
53+
#pragma comment(lib, "rstrtmgr.lib")
5354
#endif
5455

5556
namespace duckdb {

src/statement.cpp

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -161,15 +161,25 @@ static Napi::Value convert_col_val(Napi::Env &env, duckdb::Value dval, duckdb::L
161161
case duckdb::LogicalTypeId::DOUBLE: {
162162
value = Napi::Number::New(env, duckdb::DoubleValue::Get(dval));
163163
} break;
164+
case duckdb::LogicalTypeId::UHUGEINT: {
165+
auto val = duckdb::UhugeIntValue::Get(dval);
166+
const uint64_t words[] = {val.lower, val.upper};
167+
value = Napi::BigInt::New(env, false, 2, words);
168+
} break;
164169
case duckdb::LogicalTypeId::HUGEINT: {
165170
auto val = duckdb::HugeIntValue::Get(dval);
166-
auto negative = val.upper < 0;
167-
if (negative) {
168-
duckdb::Hugeint::NegateInPlace(val); // remove signing bit
171+
const uint64_t words_min[] = {0, 1ull<<63};
172+
if (val == duckdb::NumericLimits<duckdb::hugeint_t>::Minimum()) {
173+
value = Napi::BigInt::New(env, true, 2, words_min);
174+
} else {
175+
auto negative = val.upper < 0;
176+
if (negative) {
177+
duckdb::Hugeint::NegateInPlace(val); // remove signing bit
178+
}
179+
D_ASSERT(val.upper >= 0);
180+
const uint64_t words[] = {val.lower, static_cast<uint64_t>(val.upper)};
181+
value = Napi::BigInt::New(env, negative, 2, words);
169182
}
170-
D_ASSERT(val.upper >= 0);
171-
const uint64_t words[] = {val.lower, static_cast<uint64_t>(val.upper)};
172-
value = Napi::BigInt::New(env, negative, 2, words);
173183
} break;
174184
case duckdb::LogicalTypeId::DECIMAL: {
175185
value = Napi::Number::New(env, dval.GetValue<double>());

test/columns.test.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('Column Types', function() {
1212

1313
let cols = stmt.columns();
1414

15-
assert.equal(cols.length, 42);
15+
assert.equal(cols.length, 43);
1616

1717
var expected = [
1818
{ name: 'bool', type: { id: 'BOOLEAN', sql_type: 'BOOLEAN' } },
@@ -21,6 +21,7 @@ describe('Column Types', function() {
2121
{ name: 'int', type: { id: 'INTEGER', sql_type: 'INTEGER' } },
2222
{ name: 'bigint', type: { id: 'BIGINT', sql_type: 'BIGINT' } },
2323
{ name: 'hugeint', type: { id: 'HUGEINT', sql_type: 'HUGEINT' } },
24+
{ name: 'uhugeint', type: { id: 'UHUGEINT', sql_type: 'UHUGEINT' } },
2425
{ name: 'utinyint', type: { id: 'UTINYINT', sql_type: 'UTINYINT' } },
2526
{ name: 'usmallint', type: { id: 'USMALLINT', sql_type: 'USMALLINT' } },
2627
{ name: 'uint', type: { id: 'UINTEGER', sql_type: 'UINTEGER' } },

test/test_all_types.test.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,13 @@ const correct_answer_map: Record<string, any[]> = {
4848
int: [-2147483648, 2147483647, null],
4949
bigint: [BigInt("-9223372036854775808"), BigInt("9223372036854775807"), null],
5050

51+
uhugeint: [
52+
BigInt("0"),
53+
BigInt("340282366920938463463374607431768211455"),
54+
null,
55+
],
5156
hugeint: [
52-
BigInt("-170141183460469231731687303715884105727"),
57+
BigInt("-170141183460469231731687303715884105728"),
5358
BigInt("170141183460469231731687303715884105727"),
5459
null,
5560
],
@@ -60,7 +65,7 @@ const correct_answer_map: Record<string, any[]> = {
6065
uint: [0, 4294967295, null],
6166
ubigint: [BigInt(0), BigInt("18446744073709551615"), null],
6267

63-
time: ["00:00:00", "23:59:59.999999", null],
68+
time: ["00:00:00", "24:00:00", null],
6469

6570
float: [-3.4028234663852886e38, 3.4028234663852886e38, null],
6671
double: [-1.7976931348623157e308, 1.7976931348623157e308, null],
@@ -74,7 +79,7 @@ const correct_answer_map: Record<string, any[]> = {
7479
null,
7580
],
7681
uuid: [
77-
"00000000-0000-0000-0000-000000000001",
82+
"00000000-0000-0000-0000-000000000000",
7883
"ffffffff-ffff-ffff-ffff-ffffffffffff",
7984
null,
8085
],
@@ -161,7 +166,7 @@ const correct_answer_map: Record<string, any[]> = {
161166
map: ["{}", "{key1=🦆🦆🦆🦆🦆🦆, key2=goose}", null],
162167
union: ["Frank", "5", null],
163168

164-
time_tz: ["00:00:00-1559", "23:59:59.999999+1559", null],
169+
time_tz: ["00:00:00+15:59:59", "24:00:00-15:59:59", null],
165170
interval: [
166171
timedelta({
167172
days: 0,

0 commit comments

Comments
 (0)