@@ -310,11 +310,11 @@ Value Util::TransformNapiValue(
310310 case LogicalTypeID::BOOL: {
311311 return Value (napiValue.ToBoolean ().Value ());
312312 }
313- case LogicalTypeID::INT16 : {
313+ case LogicalTypeID::INT64 : {
314314 if (!napiValue.IsNumber ()) {
315315 throw Exception (" Expected a number for parameter " + key + " ." );
316316 }
317- int16_t val = napiValue.ToNumber ().Int32Value ();
317+ int64_t val = napiValue.ToNumber ().Int64Value ();
318318 return Value (val);
319319 }
320320 case LogicalTypeID::INT32: {
@@ -324,18 +324,65 @@ Value Util::TransformNapiValue(
324324 int32_t val = napiValue.ToNumber ().Int32Value ();
325325 return Value (val);
326326 }
327- case LogicalTypeID::INT64 : {
327+ case LogicalTypeID::INT16 : {
328328 if (!napiValue.IsNumber ()) {
329329 throw Exception (" Expected a number for parameter " + key + " ." );
330330 }
331- int64_t val = napiValue.ToNumber ().Int64Value ();
331+ int16_t val = napiValue.ToNumber ().Int32Value ();
332332 return Value (val);
333333 }
334- case LogicalTypeID::FLOAT : {
334+ case LogicalTypeID::INT8 : {
335335 if (!napiValue.IsNumber ()) {
336336 throw Exception (" Expected a number for parameter " + key + " ." );
337337 }
338- float val = napiValue.ToNumber ().FloatValue ();
338+ int8_t val = napiValue.ToNumber ().Int32Value ();
339+ return Value (val);
340+ }
341+ case LogicalTypeID::UINT64: {
342+ if (!napiValue.IsNumber ()) {
343+ throw Exception (" Expected a number for parameter " + key + " ." );
344+ }
345+ auto valStr = napiValue.ToNumber ().ToString ();
346+ uint64_t val = std::stoull (valStr);
347+ return Value (val);
348+ }
349+ case LogicalTypeID::UINT32: {
350+ if (!napiValue.IsNumber ()) {
351+ throw Exception (" Expected a number for parameter " + key + " ." );
352+ }
353+ uint32_t val = napiValue.ToNumber ().Uint32Value ();
354+ return Value (val);
355+ }
356+ case LogicalTypeID::UINT16: {
357+ if (!napiValue.IsNumber ()) {
358+ throw Exception (" Expected a number for parameter " + key + " ." );
359+ }
360+ uint16_t val = napiValue.ToNumber ().Uint32Value ();
361+ return Value (val);
362+ }
363+ case LogicalTypeID::UINT8: {
364+ if (!napiValue.IsNumber ()) {
365+ throw Exception (" Expected a number for parameter " + key + " ." );
366+ }
367+ uint8_t val = napiValue.ToNumber ().Uint32Value ();
368+ return Value (val);
369+ }
370+ case LogicalTypeID::INT128: {
371+ if (!napiValue.IsBigInt ()) {
372+ throw Exception (" Expected a BigInt for parameter " + key + " ." );
373+ }
374+ auto bigInt = napiValue.As <Napi::BigInt>();
375+ size_t wordsCount = bigInt.WordCount ();
376+ std::unique_ptr<uint64_t []> words (new uint64_t [wordsCount]);
377+ int signBit;
378+ bigInt.ToWords (&signBit, &wordsCount, words.get ());
379+ kuzu::common::int128_t val;
380+ val.low = words[0 ];
381+ val.high = words[1 ];
382+ // Ignore words[2] and beyond as we only support 128-bit integers but BigInt can be larger.
383+ if (signBit) {
384+ kuzu::common::Int128_t::negateInPlace (val);
385+ }
339386 return Value (val);
340387 }
341388 case LogicalTypeID::DOUBLE: {
@@ -345,9 +392,12 @@ Value Util::TransformNapiValue(
345392 double val = napiValue.ToNumber ().DoubleValue ();
346393 return Value (val);
347394 }
348- case LogicalTypeID::STRING: {
349- std::string val = napiValue.ToString ().Utf8Value ();
350- return Value (LogicalType::STRING (), val);
395+ case LogicalTypeID::FLOAT: {
396+ if (!napiValue.IsNumber ()) {
397+ throw Exception (" Expected a number for parameter " + key + " ." );
398+ }
399+ float val = napiValue.ToNumber ().FloatValue ();
400+ return Value (val);
351401 }
352402 case LogicalTypeID::DATE: {
353403 if (!napiValue.IsDate ()) {
@@ -416,6 +466,15 @@ Value Util::TransformNapiValue(
416466 auto normalizedInterval = interval_t (normalizedMonths, normalizedDays, normalizedMicros);
417467 return Value (normalizedInterval);
418468 }
469+ case LogicalTypeID::STRING: {
470+ std::string val = napiValue.ToString ().Utf8Value ();
471+ return Value (LogicalType::STRING (), val);
472+ }
473+ case LogicalTypeID::UUID: {
474+ std::string stringVal = napiValue.ToString ().Utf8Value ();
475+ auto val = UUID::fromString (stringVal);
476+ return Value (val);
477+ }
419478 default :
420479 throw Exception (
421480 " Unsupported type " + expectedDataType->toString () + " for parameter: " + key);
0 commit comments