Skip to content

Commit dfe12e4

Browse files
author
Kuzu CI
committed
java & c & nodejs api
1 parent 1bb85bd commit dfe12e4

2 files changed

Lines changed: 15 additions & 9 deletions

File tree

src_cpp/node_util.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,14 @@ Napi::Value Util::ConvertToNapiObject(const Value& value, Napi::Env env) {
5757
case LogicalTypeID::DOUBLE: {
5858
return Napi::Number::New(env, value.getValue<double>());
5959
}
60+
case LogicalTypeID::UUID:
6061
case LogicalTypeID::STRING: {
6162
return Napi::String::New(env, value.getValue<std::string>());
6263
}
6364
case LogicalTypeID::BLOB: {
6465
auto blobVal = value.getValue<std::string>();
6566
return Napi::Buffer<char>::Copy(env, blobVal.c_str(), blobVal.size());
6667
}
67-
case LogicalTypeID::UUID: {
68-
auto val = value.getValue<kuzu::common::int128_t>();
69-
auto negative = val.high < 0;
70-
if (negative) {
71-
kuzu::common::Int128_t::negateInPlace(val);
72-
}
73-
const uint64_t words[] = {val.low, static_cast<uint64_t>(val.high)};
74-
return Napi::BigInt::New(env, negative, 2, words);
75-
}
7668
case LogicalTypeID::DATE: {
7769
auto dateVal = value.getValue<date_t>();
7870
// Javascript Date type contains both date and time information. This returns the Date at

test/test_data_type.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,20 @@ describe("BLOB", function () {
201201
});
202202
});
203203

204+
describe("UUID", function () {
205+
it("should convert UUID type", async function () {
206+
const queryResult = await conn.query(
207+
"RETURN UUID('A0EEBC99-9C0B-4EF8-BB6D-6BB9BD380A11');"
208+
);
209+
const result = await queryResult.getAll();
210+
assert.equal(result.length, 1);
211+
assert.equal(Object.keys(result[0]).length, 1);
212+
const value = Object.values(result[0])[0];
213+
assert.equal(typeof value, "string");
214+
assert.equal(value, "a0eebc99-9c0b-4ef8-bb6d-6bb9bd380a11");
215+
});
216+
});
217+
204218
describe("DATE", function () {
205219
it("should convert DATE type", async function () {
206220
const queryResult = await conn.query(

0 commit comments

Comments
 (0)