@mastra/pg 1.14.1-alpha.1 → 1.14.2-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/dist/index.js CHANGED
@@ -160,7 +160,7 @@ var createNumericOperator = (symbol) => {
160
160
  const isNumeric = typeof value === "number" || typeof value === "string" && !isNaN(Number(value)) && value.trim() !== "";
161
161
  if (isNumeric) {
162
162
  return {
163
- sql: `(metadata#>>'{${jsonPathKey}}')::numeric ${symbol} $${paramIndex}::numeric`,
163
+ sql: `(CASE WHEN jsonb_typeof(metadata#>'{${jsonPathKey}}') = 'number' THEN (metadata#>>'{${jsonPathKey}}')::numeric ${symbol} $${paramIndex}::numeric ELSE FALSE END)`,
164
164
  needsValue: true
165
165
  };
166
166
  } else {
@@ -201,7 +201,7 @@ function buildElemMatchConditions(value, paramIndex) {
201
201
  throw new Error(`Invalid operator: ${paramOperator}`);
202
202
  }
203
203
  const result = operatorFn(paramKey, nextParamIndex, paramValue);
204
- const sql = result.sql.replaceAll("metadata#>>", "elem#>>");
204
+ const sql = result.sql.replaceAll("metadata#>>", "elem#>>").replaceAll("metadata#>", "elem#>");
205
205
  conditions.push(sql);
206
206
  if (result.needsValue) {
207
207
  values.push(paramValue);