cc-query 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/query-session.js +10 -0
package/package.json
CHANGED
package/src/query-session.js
CHANGED
|
@@ -39,6 +39,16 @@ function formatResults(result) {
|
|
|
39
39
|
const ms = Number(val.micros) / 1000;
|
|
40
40
|
return new Date(ms).toISOString().replace("T", " ").replace("Z", "");
|
|
41
41
|
}
|
|
42
|
+
// Handle DuckDB UUID objects (returned as {hugeint: string})
|
|
43
|
+
if ("hugeint" in val) {
|
|
44
|
+
// Convert 128-bit signed decimal to UUID hex string
|
|
45
|
+
// DuckDB XORs the high bit for sorting, so flip it back
|
|
46
|
+
let n = BigInt(val.hugeint);
|
|
47
|
+
if (n < 0n) n += 1n << 128n; // Convert from signed to unsigned
|
|
48
|
+
n ^= 1n << 127n; // Flip high bit (undo DuckDB's sort optimization)
|
|
49
|
+
const hex = n.toString(16).padStart(32, "0");
|
|
50
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
51
|
+
}
|
|
42
52
|
return JSON.stringify(val, (_, v) =>
|
|
43
53
|
typeof v === "bigint" ? v.toString() : v,
|
|
44
54
|
);
|