@crvouga/mockingbird-service-postgres 3.9.0 → 3.10.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/wire/cli.js CHANGED
@@ -3798,7 +3798,7 @@ async function preflightFleet(config, options2) {
3798
3798
  break;
3799
3799
  }
3800
3800
  }
3801
- targets.set(name2, { ...target, packageVersion: packageVersion ?? "3.9.0" });
3801
+ targets.set(name2, { ...target, packageVersion: packageVersion ?? "3.10.0" });
3802
3802
  } catch (error) {
3803
3803
  throw new Error(`service ${name2}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
3804
3804
  }
@@ -19016,6 +19016,45 @@ function validateCaseSubExpr(ctx, scope, e) {
19016
19016
  return;
19017
19017
  }
19018
19018
  }
19019
+ function caseBranchType(ctx, scope, e) {
19020
+ switch (e.type) {
19021
+ case "null_lit":
19022
+ case "string_lit":
19023
+ return UNKNOWN;
19024
+ case "number_lit":
19025
+ return numberLitValue(e.raw).t;
19026
+ case "bool_lit":
19027
+ return "bool";
19028
+ case "colref":
19029
+ return scope.lookupColumn(e.parts)?.t ?? null;
19030
+ case "cast":
19031
+ return resolveTypeName(ctx.state, e.target).column.id;
19032
+ case "collate":
19033
+ return caseBranchType(ctx, scope, e.expr);
19034
+ case "binop": {
19035
+ const left = caseBranchType(ctx, scope, e.left);
19036
+ if (left !== "json" && left !== "jsonb") return null;
19037
+ if (e.op === "->" || e.op === "#>") return left;
19038
+ if (e.op === "->>" || e.op === "#>>") return "text";
19039
+ return null;
19040
+ }
19041
+ case "case": {
19042
+ let type = UNKNOWN;
19043
+ const branches = [...e.whens.map((w) => w.then), ...e.elseExpr ? [e.elseExpr] : []];
19044
+ for (const branch of branches) {
19045
+ const next = caseBranchType(ctx, scope, branch);
19046
+ if (next === null) return null;
19047
+ if (next === UNKNOWN) continue;
19048
+ const unified = unifyTypes(type, next);
19049
+ if (unified === null) return null;
19050
+ type = unified;
19051
+ }
19052
+ return type;
19053
+ }
19054
+ default:
19055
+ return null;
19056
+ }
19057
+ }
19019
19058
  function evalCase(ctx, scope, e) {
19020
19059
  validateSearchedCaseTree(ctx, scope, e);
19021
19060
  let chosen = null;
@@ -19039,8 +19078,10 @@ function evalCase(ctx, scope, e) {
19039
19078
  }
19040
19079
  }
19041
19080
  const resultExpr = chosen ?? e.elseExpr;
19042
- if (resultExpr === null) return tv(UNKNOWN, null);
19043
- return evalExpr(ctx, scope, resultExpr);
19081
+ const result = resultExpr === null ? tv(UNKNOWN, null) : evalExpr(ctx, scope, resultExpr);
19082
+ if (result.t !== UNKNOWN) return result;
19083
+ const type = caseBranchType(ctx, scope, e);
19084
+ return type !== null && type !== UNKNOWN ? castTo(ctx, result, type, {}) : result;
19044
19085
  }
19045
19086
  function evalIn(ctx, scope, e) {
19046
19087
  const left = evalExpr(ctx, scope, e.left);