@leonardovida-md/drizzle-neo-duckdb 2.2.0 → 2.6.0

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/dist/helpers.mjs CHANGED
@@ -124,6 +124,13 @@ function splitTopLevel(input, delimiter) {
124
124
 
125
125
  // src/time.ts
126
126
  var MICROS_PER_DAY = 86400000000n;
127
+ var droppedMicros = new WeakMap;
128
+ function dateSubMillisecondMicros(date) {
129
+ return droppedMicros.get(date) ?? 0;
130
+ }
131
+ function dateToMicros(date) {
132
+ return BigInt(date.getTime()) * 1000n + BigInt(dateSubMillisecondMicros(date));
133
+ }
127
134
  function pad(value, length) {
128
135
  return value.toString().padStart(length, "0");
129
136
  }
@@ -583,8 +590,8 @@ function timestampLiteral(value, withTimezone) {
583
590
  const fraction = parts.fraction ? `.${parts.fraction}` : "";
584
591
  const offset = parts.offset === "Z" ? "+00" : parts.offset;
585
592
  if (withTimezone) {
586
- const time2 = ` ${parts.time ?? "00:00:00"}`;
587
- return `${parts.date}${time2}${fraction}${offset ?? "+00"}`;
593
+ const time = ` ${parts.time ?? "00:00:00"}`;
594
+ return `${parts.date}${time}${fraction}${offset ?? "+00"}`;
588
595
  }
589
596
  if (offset && !/^[+-]00(:00)?$/.test(offset)) {
590
597
  const utc = utcTimestampString(parts);
@@ -597,7 +604,7 @@ function timestampLiteral(value, withTimezone) {
597
604
  }
598
605
  function timestampModeString(value, withTimezone) {
599
606
  if (value instanceof Date) {
600
- return timestampStringFromMicros(BigInt(value.getTime()) * 1000n, withTimezone);
607
+ return timestampStringFromMicros(dateToMicros(value), withTimezone);
601
608
  }
602
609
  if (value !== null && typeof value === "object" && "micros" in value && typeof value.micros === "bigint") {
603
610
  return timestampStringFromMicros(value.micros, withTimezone);
@@ -701,19 +708,19 @@ function duckDbArrayOverlaps(column, values) {
701
708
  return sql`array_has_any(${column}, ${rhs})`;
702
709
  }
703
710
  export {
704
- duckDbUnion,
705
- duckDbTimestamp,
706
- duckDbTime,
707
- duckDbStruct,
708
- duckDbMap,
709
- duckDbList,
710
- duckDbJson,
711
- duckDbInterval,
712
- duckDbInet,
713
- duckDbDate,
714
- duckDbBlob,
715
- duckDbArrayOverlaps,
716
- duckDbArrayContains,
711
+ duckDbArray,
717
712
  duckDbArrayContained,
718
- duckDbArray
713
+ duckDbArrayContains,
714
+ duckDbArrayOverlaps,
715
+ duckDbBlob,
716
+ duckDbDate,
717
+ duckDbInet,
718
+ duckDbInterval,
719
+ duckDbJson,
720
+ duckDbList,
721
+ duckDbMap,
722
+ duckDbStruct,
723
+ duckDbTime,
724
+ duckDbTimestamp,
725
+ duckDbUnion
719
726
  };