@mastra/duckdb 1.6.2 → 1.6.3-alpha.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/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # @mastra/duckdb
2
2
 
3
+ ## 1.6.3-alpha.0
4
+
5
+ ### Patch Changes
6
+
7
+ - Fixed metadata filters conflating value types — `{ count: 5 }` no longer matches a stored string `'5'`, and filtering on `null` metadata values now works. Nested object filters now compare structurally, so key serialization order doesn't affect matching. ([#22047](https://github.com/mastra-ai/mastra/pull/22047))
8
+
9
+ - Updated dependencies [[`e737014`](https://github.com/mastra-ai/mastra/commit/e737014e0fc7035759762bb5b48baef1d6c0f6a7), [`d6ce34a`](https://github.com/mastra-ai/mastra/commit/d6ce34aeceb06ddf3d595a1eed5cc74f481a46a1), [`e6f8450`](https://github.com/mastra-ai/mastra/commit/e6f845074d478527026b18d85031b23353e1d0a4)]:
10
+ - @mastra/core@1.62.0-alpha.2
11
+
3
12
  ## 1.6.2
4
13
 
5
14
  ### Patch Changes
@@ -3,7 +3,7 @@ name: mastra-duckdb
3
3
  description: Documentation for @mastra/duckdb. Use when working with @mastra/duckdb APIs, configuration, or implementation.
4
4
  metadata:
5
5
  package: "@mastra/duckdb"
6
- version: "1.6.2"
6
+ version: "1.6.3-alpha.0"
7
7
  ---
8
8
 
9
9
  ## When to use
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.6.2",
2
+ "version": "1.6.3-alpha.0",
3
3
  "package": "@mastra/duckdb",
4
4
  "exports": {},
5
5
  "modules": {}
package/dist/index.cjs CHANGED
@@ -523,7 +523,7 @@ var ObservabilityStorageDuckDB = class extends _mastra_core_storage.Observabilit
523
523
  async loadDelegate() {
524
524
  if (this.delegate) return this.delegate;
525
525
  if (this.unavailableError) return null;
526
- if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-CFxG438n.cjs")).then(({ ObservabilityStorageDuckDB }) => {
526
+ if (!this.loadPromise) this.loadPromise = Promise.resolve().then(() => require("./observability-CRajwPel.cjs")).then(({ ObservabilityStorageDuckDB }) => {
527
527
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
528
528
  this.delegate = delegate;
529
529
  return delegate;
package/dist/index.js CHANGED
@@ -522,7 +522,7 @@ var ObservabilityStorageDuckDB = class extends ObservabilityStorage {
522
522
  async loadDelegate() {
523
523
  if (this.delegate) return this.delegate;
524
524
  if (this.unavailableError) return null;
525
- if (!this.loadPromise) this.loadPromise = import("./observability-ConPdXWi.js").then(({ ObservabilityStorageDuckDB }) => {
525
+ if (!this.loadPromise) this.loadPromise = import("./observability-DKGgFpq7.js").then(({ ObservabilityStorageDuckDB }) => {
526
526
  const delegate = new ObservabilityStorageDuckDB({ db: this.db });
527
527
  this.delegate = delegate;
528
528
  return delegate;
@@ -499,9 +499,43 @@ function buildJsonPath(key) {
499
499
  }
500
500
  function normalizeJsonFilterValue(value) {
501
501
  if (value === void 0) return null;
502
- if (typeof value === "string") return value;
503
502
  return JSON.stringify(value) ?? null;
504
503
  }
504
+ /**
505
+ * Add structural equality conditions for a JSON value at `path` inside `column`.
506
+ *
507
+ * Scalars compare against their raw JSON text (preserving types: 5 !== '5',
508
+ * null matches JSON null). Objects and arrays are decomposed recursively into
509
+ * per-leaf comparisons plus key/length-count checks, so nested objects match
510
+ * regardless of key serialization order while still requiring complete
511
+ * (exact, not partial) equality.
512
+ */
513
+ function addStructuralJsonConditions(column, path, value, conditions, params) {
514
+ if (value !== null && typeof value === "object") {
515
+ if (Array.isArray(value)) {
516
+ conditions.push(`json_array_length(${column}, ?) = ?`);
517
+ params.push(path, value.length);
518
+ value.forEach((item, i) => {
519
+ addStructuralJsonConditions(column, `${path}[${i}]`, item, conditions, params);
520
+ });
521
+ } else {
522
+ const entries = Object.entries(value).filter(([, v]) => v !== void 0);
523
+ conditions.push(`json_array_length(json_keys(${column}, ?)) = ?`);
524
+ params.push(path, entries.length);
525
+ for (const [subKey, subValue] of entries) addStructuralJsonConditions(column, `${path}."${subKey.replace(/\\/g, "\\\\").replace(/"/g, "\\\"")}"`, subValue, conditions, params);
526
+ }
527
+ return;
528
+ }
529
+ if (typeof value === "number") {
530
+ conditions.push(`(json_type(${column}, ?) IN ('UBIGINT', 'BIGINT', 'DOUBLE') AND CAST(json_extract(${column}, ?) AS DOUBLE) = ?)`);
531
+ params.push(path, path, value);
532
+ return;
533
+ }
534
+ const normalized = normalizeJsonFilterValue(value);
535
+ if (normalized === null) return;
536
+ conditions.push(`CAST(json_extract(${column}, ?) AS VARCHAR) = ?`);
537
+ params.push(path, normalized);
538
+ }
505
539
  function sanitizeColumn(column) {
506
540
  return (0, _mastra_core_utils.parseFieldKey)(column);
507
541
  }
@@ -560,10 +594,8 @@ function buildWhereClause(filters, fieldMappings) {
560
594
  if (key === "metadata" || key === "scope") {
561
595
  const jsonObj = value;
562
596
  for (const [jsonKey, jsonValue] of Object.entries(jsonObj)) {
563
- const normalized = normalizeJsonFilterValue(jsonValue);
564
- if (normalized === null) continue;
565
- conditions.push(`json_extract_string(${column}, ?) = ?`);
566
- params.push(buildJsonPath(jsonKey), normalized);
597
+ if (jsonValue === void 0) continue;
598
+ addStructuralJsonConditions(column, buildJsonPath(jsonKey), jsonValue, conditions, params);
567
599
  }
568
600
  continue;
569
601
  }
@@ -3777,4 +3809,4 @@ var ObservabilityStorageDuckDB = class extends _mastra_core_storage.Observabilit
3777
3809
  //#endregion
3778
3810
  exports.ObservabilityStorageDuckDB = ObservabilityStorageDuckDB;
3779
3811
 
3780
- //# sourceMappingURL=observability-CFxG438n.cjs.map
3812
+ //# sourceMappingURL=observability-CRajwPel.cjs.map