@nongt/visql 0.10.0 → 0.10.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/README.md CHANGED
@@ -32,7 +32,10 @@ grouping, then SELECT, then sorting and paging.
32
32
  - Sub queries, UNION ALL and WITH, each edited on its own canvas. These are
33
33
  off until you turn them on.
34
34
  - A Run button that hands the query to your backend and shows the rows it
35
- returns.
35
+ returns, and a Check performance button that shows what the database's
36
+ query plan says: a table read whole, an index it would need, a big sort.
37
+ The plan readers for PostgreSQL, SQL Server and MySQL are in the server
38
+ package.
36
39
  - Undo and redo, read-only mode, per-user table and column visibility,
37
40
  translations, themes, right-to-left and vertical layouts, and a
38
41
  swappable UI kit (MUI is the default).
@@ -3,11 +3,11 @@ import { createContext as _e, useContext as Re, forwardRef as So, useMemo as we,
3
3
  import Y from "clsx";
4
4
  import { NavArrowDownSolid as Nt, Trash as ft, Plus as Gn, DatabaseScript as Co, EditPencil as hd, Xmark as To, Expand as $n, NavArrowUpSolid as kt, NetworkLeft as Eo, MinusSquare as gs, PlusCircleSolid as jt, CheckSquareSolid as Va, Square as Wa, WarningTriangle as ko, KeyframesPlus as pd, Collapse as fd, MinusSquareDashed as md, Search as gd, XmarkCircleSolid as Ka, DashboardSpeed as Bo, Play as bd } from "iconoir-react";
5
5
  import { useNodeId as yd, useStore as ns, Position as Te, Handle as Ee, useReactFlow as wr, useUpdateNodeInternals as Oo, useStoreApi as xd, useInternalNode as vd, ViewportPortal as wd, Background as Nd, BackgroundVariant as zs, useNodesState as Ya, useEdgesState as Ja, applyNodeChanges as Xa, ReactFlow as Za, Controls as ec, ReactFlowProvider as tc } from "@xyflow/react";
6
- import { V as Id, C as gt, W as io, X as nc, Y as rc, Z as sc, _ as oc, $ as bs, D as ic, S as Sd, T as Cd, a0 as Td, a1 as Ed, a2 as kd, z as Bd, A as Li, a3 as Od, a4 as Ad, a5 as qd, a6 as Dd, b as Rd, a as Ao, R as Fd, a7 as Ld, M as Pd, w as ac, a8 as Md, a9 as Mr, aa as cc, ab as Pi, H as _d, ac as jd, ad as $d, c as Us, p as zd, ae as it, af as Ud, F as cr, ag as Gd, ah as Mi, ai as Hd, aj as Qd, ak as Vd, al as _i, am as ji, an as lc, n as Wd, m as Kd, ao as $i, E as zi, e as Ui, s as Yd, f as Jd, l as Xd, j as Gi, h as Zd, u as eu, r as tu, g as nu, ap as Hi, aq as Gs, ar as Hs, as as Qi, at as ru, d as su } from "./params-kc6eNrpu.js";
6
+ import { V as Id, C as gt, W as io, X as nc, Y as rc, Z as sc, _ as oc, $ as bs, D as ic, S as Sd, T as Cd, a0 as Td, a1 as Ed, a2 as kd, z as Bd, A as Li, a3 as Od, a4 as Ad, a5 as qd, a6 as Dd, b as Rd, a as Ao, R as Fd, a7 as Ld, M as Pd, w as ac, a8 as Md, a9 as Mr, aa as cc, ab as Pi, H as _d, ac as jd, ad as $d, c as Us, p as zd, ae as it, af as Ud, F as cr, ag as Gd, ah as Mi, ai as Hd, aj as Qd, ak as Vd, al as _i, am as ji, an as lc, n as Wd, m as Kd, ao as $i, E as zi, e as Ui, s as Yd, f as Jd, l as Xd, j as Gi, h as Zd, u as eu, r as tu, g as nu, ap as Hi, aq as Gs, ar as Hs, as as Qi, at as ru, d as su } from "./params-DkVFbMQn.js";
7
7
  import { t as ou, d as dc, a as iu, s as uc, i as hc, b as au } from "./calendarDate-CYlr9TvX.js";
8
8
  import { t as rs, R as pc, a as cu, D as Vi, r as lu, d as du } from "./tokens-DV5rTGMj.js";
9
- import { D as Hn, I as Qt, G as ys, t as Tt, j as Ve, L as fc, r as mc, E as gc, c as uu, S as hu, T as pu, l as Jt, z as In, U as fu, M as Nr, p as bc, V as yc, O as mu, W as xc, i as ao, q as Wr, u as gu, X as vc, n as wc, o as bu, y as yu, f as xu, A as vu, v as wu, h as ss, Y as Wi, Z as Nu, F as Iu, b as Su } from "./schema-KDJ1rpG5.js";
10
- import { o as Ki, p as Nc, k as Yi, q as Cu, t as Tu, n as Ic, v as Eu, e as ku, d as Bu, a as Ou, u as Au, r as qu, c as Du, b as Ru, m as Fu, j as Lu } from "./issueLocation-Y1iaP_Cs.js";
9
+ import { D as Hn, I as Qt, G as ys, t as Tt, j as Ve, L as fc, r as mc, E as gc, c as uu, S as hu, T as pu, l as Jt, z as In, U as fu, M as Nr, p as bc, V as yc, O as mu, W as xc, i as ao, q as Wr, u as gu, X as vc, n as wc, o as bu, y as yu, f as xu, A as vu, v as wu, h as ss, Y as Wi, Z as Nu, F as Iu, b as Su } from "./schema-CgL10bid.js";
10
+ import { o as Ki, p as Nc, k as Yi, q as Cu, t as Tu, n as Ic, v as Eu, e as ku, d as Bu, a as Ou, u as Au, r as qu, c as Du, b as Ru, m as Fu, j as Lu } from "./issueLocation-BlQ280IE.js";
11
11
  import { createPortal as Pu } from "react-dom";
12
12
  const qo = _e(!1);
13
13
  function We() {
package/dist/core.js CHANGED
@@ -1,13 +1,13 @@
1
1
  var N = Object.defineProperty;
2
2
  var I = (e, t, r) => t in e ? N(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
3
3
  var E = (e, t, r) => I(e, typeof t != "symbol" ? t + "" : t, r);
4
- import { l as T, q as A, t as B, h as O } from "./schema-KDJ1rpG5.js";
5
- import { D as le, E as pe, M as ce, b as de, f as ye, a as fe, c as me, i as he, r as be, s as Se, v as we } from "./schema-KDJ1rpG5.js";
6
- import { au as D, t as L, av as Q, F as M, $ as U, p as d, al as _, aw as i, ah as j } from "./params-kc6eNrpu.js";
7
- import { M as Ee, a as Te, b as ve, d as Ne, e as Ie, f as Ae, g as Be, c as Oe, h as De, k as Le, m as Qe, q as Me, r as Ue, i as _e, s as je, j as qe, o as xe, l as Ce, n as Re, u as $e } from "./params-kc6eNrpu.js";
4
+ import { l as T, q as A, t as B, h as O } from "./schema-CgL10bid.js";
5
+ import { D as le, E as pe, M as ce, b as de, f as ye, a as fe, c as me, i as he, r as be, s as Se, v as we } from "./schema-CgL10bid.js";
6
+ import { au as D, t as L, av as Q, F as M, $ as U, p as d, al as _, aw as i, ah as j } from "./params-DkVFbMQn.js";
7
+ import { M as Ee, a as Te, b as ve, d as Ne, e as Ie, f as Ae, g as Be, c as Oe, h as De, k as Le, m as Qe, q as Me, r as Ue, i as _e, s as je, j as qe, o as xe, l as Ce, n as Re, u as $e } from "./params-DkVFbMQn.js";
8
8
  import { c as Ge, f as Je, i as Fe } from "./calendarDate-CYlr9TvX.js";
9
- import { Q as He, l as Xe, S as Ye, a as We, n as Ke, f as Ve, j as ze, m as Ze, b as et, k as tt, r as rt, c as at, g as nt, h as st, i as it, s as ot, d as ut, e as lt, v as pt } from "./issueLocation-Y1iaP_Cs.js";
10
- import { D as dt, c as yt, S as ft, a as mt, b as ht, s as bt, u as St } from "./sqlGen-Crgheqys.js";
9
+ import { Q as He, l as Xe, S as Ye, a as We, n as Ke, f as Ve, j as ze, m as Ze, b as et, k as tt, r as rt, c as at, g as nt, h as st, i as it, s as ot, d as ut, e as lt, v as pt } from "./issueLocation-BlQ280IE.js";
10
+ import { D as dt, c as yt, S as ft, a as mt, b as ht, s as bt, u as St } from "./sqlGen-C1kZwvWI.js";
11
11
  const q = (e) => typeof e == "object" && e !== null && !(e instanceof Date), v = {
12
12
  /** A column: `expr.field('orders', 'status')`. */
13
13
  field: (e, t) => ({ type: "field", table: e, column: t }),
package/dist/explain.js CHANGED
@@ -1,6 +1,6 @@
1
- import { y as Y, m as G } from "./schema-KDJ1rpG5.js";
2
- import { B as V } from "./params-kc6eNrpu.js";
3
- import { s as Z, b as tt, a as et } from "./sqlGen-Crgheqys.js";
1
+ import { y as Y, m as G } from "./schema-CgL10bid.js";
2
+ import { B as V } from "./params-DkVFbMQn.js";
3
+ import { s as Z, b as tt, a as et } from "./sqlGen-C1kZwvWI.js";
4
4
  const C = (t, e) => e.reduce(
5
5
  (s, i) => s[i],
6
6
  t
package/dist/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { D as f } from "./PipelineEditor-Ch_i6OAc.js";
2
- import { P, f as v, a as B } from "./PipelineEditor-Ch_i6OAc.js";
3
- import { D as R, E as I, M as k, b as C, f as O, a as q, c as H, h as G, i as Y, r as w, s as X, v as J } from "./schema-KDJ1rpG5.js";
4
- import { D as j, M as V, a as z, b as K, d as Z, e as $, f as ee, g as ae, c as se, h as te, k as re, m as ne, q as oe, r as ie, i as de, s as ce, j as ue, o as le, l as me, n as fe, u as he } from "./params-kc6eNrpu.js";
1
+ import { D as f } from "./PipelineEditor-CGTZGbmf.js";
2
+ import { P, f as v, a as B } from "./PipelineEditor-CGTZGbmf.js";
3
+ import { D as R, E as I, M as k, b as C, f as O, a as q, c as H, h as G, i as Y, r as w, s as X, v as J } from "./schema-CgL10bid.js";
4
+ import { D as j, M as V, a as z, b as K, d as Z, e as $, f as ee, g as ae, c as se, h as te, k as re, m as ne, q as oe, r as ie, i as de, s as ce, j as ue, o as le, l as me, n as fe, u as he } from "./params-DkVFbMQn.js";
5
5
  import { c as Ee, f as Se, i as Te } from "./calendarDate-CYlr9TvX.js";
6
- import { Q as Ae, l as Ne, S as _e, a as be, n as De, f as Ue, j as ye, m as Me, b as Qe, k as xe, r as Fe, c as Pe, g as ve, h as Be, i as Le, s as Re, d as Ie, e as ke, v as Ce } from "./issueLocation-Y1iaP_Cs.js";
7
- import { w as h, a as p, b as E } from "./sqlGen-Crgheqys.js";
8
- import { D as qe, c as He, S as Ge, s as Ye, u as we } from "./sqlGen-Crgheqys.js";
6
+ import { Q as Ae, l as Ne, S as _e, a as be, n as De, f as Ue, j as ye, m as Me, b as Qe, k as xe, r as Fe, c as Pe, g as ve, h as Be, i as Le, s as Re, d as Ie, e as ke, v as Ce } from "./issueLocation-BlQ280IE.js";
7
+ import { w as h, a as p, b as E } from "./sqlGen-C1kZwvWI.js";
8
+ import { D as qe, c as He, S as Ge, s as Ye, u as we } from "./sqlGen-C1kZwvWI.js";
9
9
  import { QUERY_FORMAT_VERSION as Je, QueryFormatError as We, addCondition as je, addGroupBy as Ve, addJoin as ze, addOrderBy as Ke, addSelectItem as Ze, expr as $e, loadQuery as ea, removeJoin as aa, requireBaseTable as sa, saveQuery as ta, setBaseTable as ra, setDistinct as na, setHaving as oa, setPaging as ia } from "./core.js";
10
10
  import { D as S, N as T } from "./tokens-DV5rTGMj.js";
11
11
  function b(n, s, e = {}) {
@@ -1,5 +1,5 @@
1
- import { l as fe, z as Je, q as be, t as X, i as $e, y as ve, d as re, o as ye, b as Ue, j as he, f as Pe, A as He, D as Ke, B as Be, C as Oe, M as K, F as We, G as ce, u as oe, H as ze, I as Ve } from "./schema-KDJ1rpG5.js";
2
- import { C as Ye, E as Ze, F as er, G as Ge, H as Le, I as rr, J as _e, K as nr, L as tr, N as sr, t as ir, O as ar, P as or, A as lr, z as cr, b as ur, Q as je, M as fr, a as dr, R as Me, S as mr, w as yr, T as hr, U as gr } from "./params-kc6eNrpu.js";
1
+ import { l as fe, z as Je, q as be, t as X, i as $e, y as ve, d as re, o as ye, b as Ue, j as he, f as Pe, A as He, D as Ke, B as Be, C as Oe, M as K, F as We, G as ce, u as oe, H as ze, I as Ve } from "./schema-CgL10bid.js";
2
+ import { C as Ye, E as Ze, F as er, G as Ge, H as Le, I as rr, J as _e, K as nr, L as tr, N as sr, t as ir, O as ar, P as or, A as lr, z as cr, b as ur, Q as je, M as fr, a as dr, R as Me, S as mr, w as yr, T as hr, U as gr } from "./params-DkVFbMQn.js";
3
3
  const we = (n) => typeof n == "object" && n !== null && !Array.isArray(n) && !(n instanceof Date), Se = (n) => typeof n.shared == "string";
4
4
  function ue(n, a) {
5
5
  if (Array.isArray(n)) {
package/dist/mui.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx as n, Fragment as ee, jsxs as P } from "react/jsx-runtime";
2
2
  import { forwardRef as N, useContext as te, createContext as oe, useMemo as H, useState as L, useRef as re, useLayoutEffect as ne } from "react";
3
- import { P as ie } from "./PipelineEditor-Ch_i6OAc.js";
3
+ import { P as ie } from "./PipelineEditor-CGTZGbmf.js";
4
4
  import le from "@emotion/cache";
5
5
  import { CacheProvider as D, __unsafe_useEmotionCache as ue } from "@emotion/react";
6
6
  import { TextField as C, Menu as ce, ListSubheader as A, MenuItem as G, Box as g, createFilterOptions as se, Autocomplete as K, Select as ae, InputBase as de, Button as pe, IconButton as me, Tooltip as fe, Chip as he } from "@mui/material";
@@ -1,4 +1,4 @@
1
- import { D as Q, h as U, q as S, t as v, i as C, J as Je, u as ne, F as jn, e as te, n as re, K as Te, j as A, y as oe, m as _, o as x, L as Pe, l as E, N as qn, O as J, z as q, r as Rn, M as D, s as Gn, P as Fn, d as M, g as se, Q as Ne, b as Y, I as Qn, x as _n, R as Ve } from "./schema-KDJ1rpG5.js";
1
+ import { D as Q, h as U, q as S, t as v, i as C, J as Je, u as ne, F as jn, e as te, n as re, K as Te, j as A, y as oe, m as _, o as x, L as Pe, l as E, N as qn, O as J, z as q, r as Rn, M as D, s as Gn, P as Fn, d as M, g as se, Q as Ne, b as Y, I as Qn, x as _n, R as Ve } from "./schema-CgL10bid.js";
2
2
  import { c as Jn, s as Pn, b as We } from "./calendarDate-CYlr9TvX.js";
3
3
  const Ot = 1e3, Vn = 15, Ut = 40, Lt = 100;
4
4
  function Wn(e) {
@@ -41,7 +41,7 @@ function ie(e) {
41
41
  function ue(e) {
42
42
  return M(e) ? e.union[0] : e;
43
43
  }
44
- function N(e, t) {
44
+ function w(e, t) {
45
45
  if (!M(e)) return t(e, 0);
46
46
  const n = e.union.map((r, i) => t(r, i));
47
47
  return n.every((r, i) => r === e.union[i]) ? e : { ...e, union: n };
@@ -71,7 +71,7 @@ function Q(e) {
71
71
  function de(e) {
72
72
  return Q(e).flatMap((t) => t.table === void 0 ? [] : [t.table]);
73
73
  }
74
- function Y(e, t) {
74
+ function $(e, t) {
75
75
  const n = t;
76
76
  switch (e.type) {
77
77
  case "function":
@@ -120,8 +120,8 @@ function Y(e, t) {
120
120
  return e;
121
121
  }
122
122
  }
123
- function $(e, t) {
124
- const n = Y(e, (r) => $(r, t));
123
+ function j(e, t) {
124
+ const n = $(e, (r) => j(r, t));
125
125
  return n === e ? t(e) : n;
126
126
  }
127
127
  function me(e) {
@@ -134,17 +134,17 @@ function me(e) {
134
134
  ...(e.orderBy ?? []).map((t) => t.expression)
135
135
  ];
136
136
  }
137
- function j(e, t, n = (r) => j(r, t)) {
137
+ function _(e, t, n = (r) => _(r, t)) {
138
138
  var a, l;
139
139
  const r = t, { shared: i } = e;
140
140
  return {
141
141
  ...e,
142
142
  ...i ? {
143
- shared: i.map((s) => ({ ...s, query: N(s.query, n) }))
143
+ shared: i.map((s) => ({ ...s, query: w(s.query, n) }))
144
144
  } : {},
145
- from: e.from.query ? { ...e.from, query: N(e.from.query, n) } : e.from,
145
+ from: e.from.query ? { ...e.from, query: w(e.from.query, n) } : e.from,
146
146
  where: e.where && r(e.where),
147
- joins: e.joins.map((s) => s.query ? { ...s, on: s.on && r(s.on), query: N(s.query, n) } : { ...s, on: s.on && r(s.on) }),
147
+ joins: e.joins.map((s) => s.query ? { ...s, on: s.on && r(s.on), query: w(s.query, n) } : { ...s, on: s.on && r(s.on) }),
148
148
  select: e.select.map((s) => ({ ...s, expression: r(s.expression) })),
149
149
  groupBy: (a = e.groupBy) == null ? void 0 : a.map((s) => ({ ...s, expression: r(s.expression) })),
150
150
  having: e.having && r(e.having),
@@ -152,8 +152,8 @@ function j(e, t, n = (r) => j(r, t)) {
152
152
  };
153
153
  }
154
154
  function J(e, t) {
155
- const n = (r) => r.type === "subquery" ? { ...r, query: J(r.query, t) } : Y(r, n);
156
- return j(e, (r) => $(n(r), t));
155
+ const n = (r) => r.type === "subquery" ? { ...r, query: J(r.query, t) } : $(r, n);
156
+ return _(e, (r) => j(n(r), t));
157
157
  }
158
158
  function z(e) {
159
159
  return new Set([e.from, ...e.joins].map(K));
@@ -193,7 +193,7 @@ const T = (e, t = "DAY") => ({
193
193
  kind: "unit",
194
194
  choices: ee,
195
195
  default: { type: "literal", value: t }
196
- }), S = {
196
+ }), A = {
197
197
  // ---- Aggregate ----
198
198
  // COUNT with no argument is COUNT(*), and `distinct` on the call makes it
199
199
  // COUNT(DISTINCT x) — see the function sub-canvas's count choice.
@@ -577,7 +577,7 @@ const T = (e, t = "DAY") => ({
577
577
  ]
578
578
  }
579
579
  };
580
- function D(e, t = S) {
580
+ function D(e, t = A) {
581
581
  return t[e.toUpperCase()];
582
582
  }
583
583
  function xe(e, t) {
@@ -587,11 +587,11 @@ function xe(e, t) {
587
587
  return (i = r.aliases) == null ? void 0 : i.some((a) => a.toUpperCase() === n);
588
588
  });
589
589
  }
590
- function te(e = S) {
590
+ function te(e = A) {
591
591
  return Object.keys(e).sort();
592
592
  }
593
- te(S);
594
- const Te = S;
593
+ te(A);
594
+ const Te = A;
595
595
  function ve(e) {
596
596
  return Object.fromEntries(Object.values(e).map((t) => {
597
597
  const n = t.name.toUpperCase();
@@ -615,55 +615,55 @@ function ne() {
615
615
  const e = globalThis.crypto.getRandomValues(new Uint8Array(12));
616
616
  return Array.from(e, (t) => t.toString(16).padStart(2, "0")).join("");
617
617
  }
618
- function _(e, t) {
618
+ function F(e, t) {
619
619
  var n;
620
620
  return e.type === "function" && ((n = D(e.name, t)) == null ? void 0 : n.aggregate) === !0;
621
621
  }
622
622
  function x(e, t) {
623
- return e ? _(e, t) || k(e).some((n) => x(n, t)) : !1;
623
+ return e ? F(e, t) || k(e).some((n) => x(n, t)) : !1;
624
624
  }
625
- function F(e, t) {
625
+ function H(e, t) {
626
626
  return e.type === "function" && e.name.trim() !== "" && D(e.name, t) === void 0;
627
627
  }
628
- function H(e, t) {
629
- return e ? F(e, t) || k(e).some((n) => H(n, t)) : !1;
628
+ function P(e, t) {
629
+ return e ? H(e, t) || k(e).some((n) => P(n, t)) : !1;
630
630
  }
631
631
  function v(e, t, n) {
632
- return t.some((r) => U(r, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? q(e).every((r) => v(r, t, n)) : _(e, n) || F(e, n) ? !0 : k(e).every((r) => v(r, t, n));
632
+ return t.some((r) => U(r, e)) ? !0 : e.type === "field" ? !e.column : e.type === "exists" ? q(e).every((r) => v(r, t, n)) : F(e, n) || H(e, n) ? !0 : k(e).every((r) => v(r, t, n));
633
633
  }
634
- function P(e, t) {
634
+ function W(e, t) {
635
635
  return (e.groupBy ?? []).length > 0 || e.having !== void 0 || [...e.select, ...e.orderBy ?? []].some((n) => x(n.expression, t));
636
636
  }
637
- function Ae(e, t) {
638
- if (P(e, t))
637
+ function Se(e, t) {
638
+ if (W(e, t))
639
639
  return (e.groupBy ?? []).flatMap(({ expression: n }) => n.type === "field" && n.table && n.column ? [`${n.table}.${n.column}`] : []);
640
640
  }
641
641
  function re(e, t) {
642
642
  return x(e.having, t) || [...e.select, ...e.orderBy ?? []].some((n) => x(n.expression, t));
643
643
  }
644
- function Re(e, t) {
644
+ function Ae(e, t) {
645
645
  return e.select.some((n) => x(n.expression, t));
646
646
  }
647
- function Se(e, t) {
648
- const n = e.groupBy ?? [], r = n.filter((o) => o.fromSelect === void 0), i = re(e, t), a = r.map((o) => o.expression), l = i ? e.select.filter((o) => x(o.expression, t) || H(o.expression, t) || v(o.expression, a, t) ? !1 : (a.push(o.expression), !0)) : [], s = new Map(n.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), f = [];
647
+ function Re(e, t) {
648
+ const n = e.groupBy ?? [], r = n.filter((o) => o.fromSelect === void 0), i = re(e, t), a = r.map((o) => o.expression), l = i ? e.select.filter((o) => x(o.expression, t) || P(o.expression, t) || v(o.expression, a, t) ? !1 : (a.push(o.expression), !0)) : [], s = new Map(n.filter((o) => o.fromSelect !== void 0).map((o) => [o.fromSelect, o])), c = [];
649
649
  n.forEach((o) => {
650
650
  if (o.fromSelect === void 0) {
651
- f.push(o);
651
+ c.push(o);
652
652
  return;
653
653
  }
654
- const p = l.find((d) => d.id === o.fromSelect);
655
- p && f.push(U(o.expression, p.expression) ? o : { ...o, expression: p.expression });
654
+ const p = l.find((m) => m.id === o.fromSelect);
655
+ p && c.push(U(o.expression, p.expression) ? o : { ...o, expression: p.expression });
656
656
  });
657
- const m = l.filter((o) => !s.has(o.id)).map((o) => ({
657
+ const h = l.filter((o) => !s.has(o.id)).map((o) => ({
658
658
  id: ne(),
659
659
  expression: o.expression,
660
660
  fromSelect: o.id
661
- })), h = [...f, ...m];
662
- return h.length === n.length && h.every((o, p) => o === n[p]) ? e : { ...e, groupBy: h };
661
+ })), g = [...c, ...h];
662
+ return g.length === n.length && g.every((o, p) => o === n[p]) ? e : { ...e, groupBy: g };
663
663
  }
664
664
  function Ce(e, t) {
665
665
  const n = (e.groupBy ?? []).map((a) => a.expression), r = e.orderBy ?? [];
666
- if (!P(e, t))
666
+ if (!W(e, t))
667
667
  return {
668
668
  select: [],
669
669
  selectAll: !1,
@@ -705,72 +705,72 @@ function Ne(e, t = (r) => r.group, n = e) {
705
705
  ...[...r].filter(([a]) => a === void 0)
706
706
  ].filter(([, a]) => a.length > 0).map(([a, l]) => ({ group: a, tables: i(l) }));
707
707
  }
708
- function W(e, t) {
708
+ function V(e, t) {
709
709
  return e.tables.find((n) => n.name === t);
710
710
  }
711
- function A(e, t, n) {
711
+ function N(e, t, n) {
712
712
  return e.relations.find((r) => r.fromTable === t && r.toTable === n || r.fromTable === n && r.toTable === t);
713
713
  }
714
- const C = (e, t) => {
714
+ const R = (e, t) => {
715
715
  var n;
716
- return ((n = W(e, t)) == null ? void 0 : n.passThrough) !== !1;
716
+ return ((n = V(e, t)) == null ? void 0 : n.passThrough) !== !1;
717
717
  };
718
718
  function I(e, t) {
719
- const n = t.filter((r) => C(e, r));
719
+ const n = t.filter((r) => R(e, r));
720
720
  return n.length > 0 ? n : [...t];
721
721
  }
722
- function V(e, t) {
722
+ function B(e, t) {
723
723
  const n = /* @__PURE__ */ new Set();
724
724
  return t.forEach((r, i) => {
725
- const l = t.slice(0, i).map((f) => ({ earlier: f, r: A(e, f, r) })).find(({ r: f }) => f !== void 0);
725
+ const l = t.slice(0, i).map((c) => ({ earlier: c, r: N(e, c, r) })).find(({ r: c }) => c !== void 0);
726
726
  if (!l) return;
727
727
  (l.r.fromTable === l.earlier && l.r.toTable === r || n.has(l.earlier)) && n.add(r);
728
728
  }), n;
729
729
  }
730
- const X = (e, t) => e.fanOuts - t.fanOuts || e.steps - t.steps || e.order - t.order, R = (e, t) => `${t ? "^" : "_"}${e}`;
731
- function L(e, t) {
730
+ const X = (e, t) => e.fanOuts - t.fanOuts || e.steps - t.steps || e.order - t.order, S = (e, t) => `${t ? "^" : "_"}${e}`;
731
+ function G(e, t) {
732
732
  let n;
733
733
  return e.forEach((r, i) => {
734
734
  !t.has(i) && (n === void 0 || X(r, e.get(n)) < 0) && (n = i);
735
735
  }), n;
736
736
  }
737
737
  function ae(e, t, n, r = {}) {
738
- const i = new Set(t), a = new Set(I(e, t)), l = r.anyShape ? /* @__PURE__ */ new Set() : V(e, t), s = /* @__PURE__ */ new Map();
739
- t.forEach((d, g) => {
740
- const b = R(d, l.has(d));
738
+ const i = new Set(t), a = new Set(I(e, t)), l = r.anyShape ? /* @__PURE__ */ new Set() : B(e, t), s = /* @__PURE__ */ new Map();
739
+ t.forEach((m, d) => {
740
+ const b = S(m, l.has(m));
741
741
  s.has(b) || s.set(b, {
742
- table: d,
743
- climbed: l.has(d),
742
+ table: m,
743
+ climbed: l.has(m),
744
744
  fanOuts: 0,
745
745
  steps: 0,
746
- order: g
746
+ order: d
747
747
  });
748
748
  });
749
- const f = new Set([...s].filter(([, d]) => !a.has(d.table)).map(([d]) => d));
750
- let m = t.length;
751
- const h = (d) => {
752
- const g = s.get(d);
753
- g.steps > 0 && !C(e, g.table) || e.relations.forEach((b) => {
754
- if (b.fromTable !== g.table && b.toTable !== g.table) return;
755
- const E = b.fromTable === g.table, O = E ? b.toTable : b.fromTable;
756
- if (i.has(O) || !E && g.climbed) return;
757
- const y = {
758
- table: O,
759
- climbed: !r.anyShape && (g.climbed || E),
760
- fanOuts: g.fanOuts + (E ? 0 : 1),
761
- steps: g.steps + 1,
762
- order: m,
763
- from: d
764
- }, w = R(O, y.climbed), B = s.get(w);
765
- f.has(w) || B && X(y, { ...B, order: m }) >= 0 || (s.set(w, y), m += 1);
749
+ const c = new Set([...s].filter(([, m]) => !a.has(m.table)).map(([m]) => m));
750
+ let h = t.length;
751
+ const g = (m) => {
752
+ const d = s.get(m);
753
+ d.steps > 0 && !R(e, d.table) || e.relations.forEach((b) => {
754
+ if (b.fromTable !== d.table && b.toTable !== d.table) return;
755
+ const E = b.fromTable === d.table, C = E ? b.toTable : b.fromTable;
756
+ if (i.has(C) || !E && d.climbed) return;
757
+ const O = {
758
+ table: C,
759
+ climbed: !r.anyShape && (d.climbed || E),
760
+ fanOuts: d.fanOuts + (E ? 0 : 1),
761
+ steps: d.steps + 1,
762
+ order: h,
763
+ from: m
764
+ }, y = S(C, O.climbed), L = s.get(y);
765
+ c.has(y) || L && X(O, { ...L, order: h }) >= 0 || (s.set(y, O), h += 1);
766
766
  });
767
767
  };
768
- let c = L(s, f);
769
- for (; c !== void 0 && s.get(c).table !== n; )
770
- f.add(c), h(c), c = L(s, f);
771
- if (c === void 0) return;
768
+ let f = G(s, c);
769
+ for (; f !== void 0 && s.get(f).table !== n; )
770
+ c.add(f), g(f), f = G(s, c);
771
+ if (f === void 0) return;
772
772
  const o = [];
773
- let p = s.get(c);
773
+ let p = s.get(f);
774
774
  for (; p.from !== void 0; )
775
775
  o.unshift(p.table), p = s.get(p.from);
776
776
  return { start: p.table, tables: o };
@@ -780,40 +780,43 @@ function Me(e, t, n, r = {}) {
780
780
  return t.includes(n) ? [] : (i = ae(e, t, n, r)) == null ? void 0 : i.tables;
781
781
  }
782
782
  function De(e, t, n = {}) {
783
- const r = /* @__PURE__ */ new Map(), i = (c, o, p) => r.set(c, [
784
- ...r.get(c) ?? [],
783
+ const r = /* @__PURE__ */ new Map(), i = (f, o, p) => r.set(f, [
784
+ ...r.get(f) ?? [],
785
785
  { table: o, up: p }
786
786
  ]);
787
- e.relations.forEach((c) => {
788
- i(c.fromTable, c.toTable, !0), i(c.toTable, c.fromTable, !1);
787
+ e.relations.forEach((f) => {
788
+ i(f.fromTable, f.toTable, !0), i(f.toTable, f.fromTable, !1);
789
789
  });
790
- const { skip: a = /* @__PURE__ */ new Set() } = n, l = n.anyShape ? /* @__PURE__ */ new Set() : V(e, t), s = new Set(t), f = new Set(t), m = I(e, t).map((c) => ({ table: c, climbed: l.has(c) })), h = new Set(m.map((c) => R(c.table, c.climbed)));
791
- for (let c = m.shift(); c !== void 0; c = m.shift()) {
792
- const o = c;
793
- (r.get(o.table) ?? []).forEach(({ table: p, up: d }) => {
794
- if (s.has(p) || a.has(p) || !d && o.climbed) return;
795
- const g = { table: p, climbed: !n.anyShape && (o.climbed || d) }, b = R(p, g.climbed);
796
- h.has(b) || (h.add(b), f.add(p), C(e, p) && m.push(g));
790
+ const { skip: a = /* @__PURE__ */ new Set() } = n, l = n.anyShape ? /* @__PURE__ */ new Set() : B(e, t), s = new Set(t), c = new Set(t), h = I(e, t).map((f) => ({ table: f, climbed: l.has(f) })), g = new Set(h.map((f) => S(f.table, f.climbed)));
791
+ for (let f = h.shift(); f !== void 0; f = h.shift()) {
792
+ const o = f;
793
+ (r.get(o.table) ?? []).forEach(({ table: p, up: m }) => {
794
+ if (s.has(p) || a.has(p) || !m && o.climbed) return;
795
+ const d = { table: p, climbed: !n.anyShape && (o.climbed || m) }, b = S(p, d.climbed);
796
+ g.has(b) || (g.add(b), c.add(p), R(e, p) && h.push(d));
797
797
  });
798
798
  }
799
- return f;
799
+ return c;
800
800
  }
801
801
  function Ue(e, t, n, r = {}) {
802
- var o;
803
- const { after: i, leftJoined: a = [] } = r;
804
- let l = C(e, n) ? I(e, t) : t;
805
- i !== void 0 && A(e, i, n) && (l = [i]);
806
- const s = l.find((p) => A(e, p, n) !== void 0);
807
- if (s === void 0) return;
808
- const f = A(e, s, n), m = (o = W(e, f.fromTable)) == null ? void 0 : o.columns.find((p) => p.name === f.fromColumn), h = m != null && m.nullable || a.includes(s) ? "left" : "inner", c = {
802
+ var m;
803
+ const { after: i, leftJoined: a = [] } = r, l = r.anyShape ? /* @__PURE__ */ new Set() : B(e, t), s = (d) => {
804
+ const b = N(e, d, n);
805
+ return b !== void 0 && !(l.has(d) && b.toTable === d && b.fromTable === n);
806
+ };
807
+ let c = R(e, n) ? I(e, t) : t;
808
+ i !== void 0 && s(i) && (c = [i]);
809
+ const h = c.find(s);
810
+ if (h === void 0) return;
811
+ const g = N(e, h, n), f = (m = V(e, g.fromTable)) == null ? void 0 : m.columns.find((d) => d.name === g.fromColumn), o = f != null && f.nullable || a.includes(h) ? "left" : "inner", p = {
809
812
  type: "binary",
810
813
  operator: "=",
811
- left: { type: "field", table: f.fromTable, column: f.fromColumn },
812
- right: { type: "field", table: f.toTable, column: f.toColumn }
814
+ left: { type: "field", table: g.fromTable, column: g.fromColumn },
815
+ right: { type: "field", table: g.toTable, column: g.toColumn }
813
816
  };
814
- return { joinType: h, on: c };
817
+ return { joinType: o, on: p };
815
818
  }
816
- const G = (e, t) => `${e}.${t}`;
819
+ const Y = (e, t) => `${e}.${t}`;
817
820
  function se({ type: e, format: t }) {
818
821
  if (t === void 0) return;
819
822
  if (e !== "date" && e !== "dateTime" && e !== "time")
@@ -836,16 +839,16 @@ function Ie(e) {
836
839
  kind: "duplicateColumn",
837
840
  message: `Column "${a.name}.${s.name}" is declared more than once`
838
841
  }), l.add(s.name);
839
- const f = se(s);
840
- f && t.push({
842
+ const c = se(s);
843
+ c && t.push({
841
844
  kind: "invalidFormat",
842
- message: `Column "${a.name}.${s.name}": ${f}`
845
+ message: `Column "${a.name}.${s.name}": ${c}`
843
846
  });
844
847
  });
845
848
  });
846
849
  const r = (a, l) => {
847
850
  const s = n.get(a);
848
- s ? s.columns.some((f) => f.name === l) || t.push({
851
+ s ? s.columns.some((c) => c.name === l) || t.push({
849
852
  kind: "unknownColumn",
850
853
  message: `Relation references unknown column "${a}.${l}"`
851
854
  }) : t.push({
@@ -855,22 +858,22 @@ function Ie(e) {
855
858
  }, i = /* @__PURE__ */ new Set();
856
859
  return e.relations.forEach((a) => {
857
860
  r(a.fromTable, a.fromColumn), r(a.toTable, a.toColumn);
858
- const l = G(a.fromTable, a.fromColumn), s = G(a.toTable, a.toColumn), f = [l, s].sort().join(" <-> ");
859
- i.has(f) && t.push({
861
+ const l = Y(a.fromTable, a.fromColumn), s = Y(a.toTable, a.toColumn), c = [l, s].sort().join(" <-> ");
862
+ i.has(c) && t.push({
860
863
  kind: "duplicateRelation",
861
864
  message: `Relation ${l} -> ${s} is declared more than once (declare each foreign key once)`
862
- }), i.add(f);
865
+ }), i.add(c);
863
866
  }), t;
864
867
  }
865
868
  export {
866
869
  ve as A,
867
- P as B,
870
+ W as B,
868
871
  le as C,
869
872
  Te as D,
870
873
  Oe as E,
871
874
  Ce as F,
872
875
  be as G,
873
- H,
876
+ P as H,
874
877
  D as I,
875
878
  me as J,
876
879
  oe as K,
@@ -879,29 +882,29 @@ export {
879
882
  Z as N,
880
883
  de as O,
881
884
  ae as P,
882
- $ as Q,
885
+ j as Q,
883
886
  J as R,
884
887
  ke as S,
885
888
  te as T,
886
889
  ge as U,
887
890
  he as V,
888
891
  Ne as W,
889
- _ as X,
890
- Ae as Y,
891
- Re as Z,
892
+ F as X,
893
+ Se as Y,
894
+ Ae as Z,
892
895
  Me as a,
893
896
  ie as b,
894
897
  Ee as c,
895
898
  U as d,
896
- j as e,
899
+ _ as e,
897
900
  ye as f,
898
- N as g,
901
+ w as g,
899
902
  fe as h,
900
903
  M as i,
901
- W as j,
904
+ V as j,
902
905
  ee as k,
903
906
  ne as l,
904
- Y as m,
907
+ $ as m,
905
908
  ue as n,
906
909
  pe as o,
907
910
  xe as p,
@@ -912,7 +915,7 @@ export {
912
915
  x as u,
913
916
  Ie as v,
914
917
  re as w,
915
- Se as x,
918
+ Re as x,
916
919
  k as y,
917
920
  we as z
918
921
  };
@@ -1,7 +1,7 @@
1
1
  var Ct = Object.defineProperty;
2
2
  var Lt = (o, T, D) => T in o ? Ct(o, T, { enumerable: !0, configurable: !0, writable: !0, value: D }) : o[T] = D;
3
3
  var It = (o, T, D) => Lt(o, typeof T != "symbol" ? T + "" : T, D);
4
- import { k as Dt, l as nt, p as gt, D as Ut, n as bt, d as Rt, o as Mt, q as qt, j as Nt, u as wt, w as xt, x as Ft, t as $t, m as Bt, y as Wt } from "./schema-KDJ1rpG5.js";
4
+ import { k as Dt, l as nt, p as gt, D as Ut, n as bt, d as Rt, o as Mt, q as qt, j as Nt, u as wt, w as xt, x as Ft, t as $t, m as Bt, y as Wt } from "./schema-CgL10bid.js";
5
5
  import { t as Pt, f as _t, a as Gt } from "./calendarDate-CYlr9TvX.js";
6
6
  function kt(o, T, D = T) {
7
7
  const k = o.slice(0, T);
@@ -1,8 +1,8 @@
1
1
  var bt = Object.defineProperty;
2
2
  var Mt = (t, r, e) => r in t ? bt(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
3
  var w = (t, r, e) => Mt(t, typeof r != "symbol" ? r + "" : r, e);
4
- import { q as _, d as F, a as Lt, s as wt, m as X, e as st, g as Ft, t as Ut, j as qt, b as _t, i as Yt } from "./schema-KDJ1rpG5.js";
5
- import { p as K, t as Z, v as Ht, w as jt, x as Pt, y as ot, z as vt, A as Bt } from "./params-kc6eNrpu.js";
4
+ import { q as _, d as F, a as Lt, s as wt, m as X, e as st, g as Ft, t as Ut, j as qt, b as _t, i as Yt } from "./schema-CgL10bid.js";
5
+ import { p as K, t as Z, v as Ht, w as jt, x as Pt, y as ot, z as vt, A as Bt } from "./params-DkVFbMQn.js";
6
6
  import { s as it } from "./calendarDate-CYlr9TvX.js";
7
7
  class Gt extends Error {
8
8
  constructor(e, n, s, i) {
@@ -62,7 +62,7 @@ function $t(t, r, e, n, s = new Set(at(r))) {
62
62
  return O ? [...A(O.ref), O.tie] : [];
63
63
  }, y = (g, O, j) => {
64
64
  if (O === g.length) return d(A(c.get(j)));
65
- const D = g[O], M = wt(t, [...c.keys()], D);
65
+ const D = g[O], M = wt(t, [...c.keys()], D, { anyShape: !0 });
66
66
  if (!M) return !1;
67
67
  const Q = c.get(Z(M.on).find((T) => T !== D)), V = (T) => B(M.on, new Map([...c, [D, T]])), J = i.includes(D), z = (T, I) => {
68
68
  c.set(D, T), f.set(T, { ref: Q, tie: I });
@@ -280,7 +280,7 @@ const gr = ["mysql", "mssql", "postgres"], yr = {
280
280
  mssql: "SQL Server",
281
281
  postgres: "PostgreSQL"
282
282
  };
283
- function S(t, r) {
283
+ function N(t, r) {
284
284
  const e = t.replace(/[\uE000-\uE003]/g, "");
285
285
  switch (r) {
286
286
  case "mysql":
@@ -592,7 +592,7 @@ const v = {
592
592
  }
593
593
  }
594
594
  };
595
- function N(t) {
595
+ function S(t) {
596
596
  return t.type === "binary" || t.type === "logical" || t.type === "if" || t.type === "case";
597
597
  }
598
598
  function E(t, r, e, n) {
@@ -602,7 +602,7 @@ function nt(t, r, e, n) {
602
602
  const s = (i) => {
603
603
  if (!i) return "??";
604
604
  const u = E(i, r, e, n);
605
- return N(i) ? `(${u})` : u;
605
+ return S(i) ? `(${u})` : u;
606
606
  };
607
607
  return m(t, () => {
608
608
  const [i, u] = t.type === "list" ? t.items : [t];
@@ -623,8 +623,8 @@ function rr(t, r, e, n) {
623
623
  }
624
624
  case "field": {
625
625
  if (!t.column) return "??";
626
- const o = S(t.column, r);
627
- return t.table ? `${S(t.table, r)}.${o}` : o;
626
+ const o = N(t.column, r);
627
+ return t.table ? `${N(t.table, r)}.${o}` : o;
628
628
  }
629
629
  case "function": {
630
630
  const o = t.args.map(($) => E($, r, e, n)), a = tr[t.name.toUpperCase()];
@@ -643,18 +643,18 @@ function rr(t, r, e, n) {
643
643
  return `${c}(${f}${o.join(", ")})`;
644
644
  }
645
645
  case "binary": {
646
- const o = t.operator ? dt(t.operator, r) : "=", a = E(t.left, r, e, n), c = N(t.left) ? `(${a})` : a;
646
+ const o = t.operator ? dt(t.operator, r) : "=", a = E(t.left, r, e, n), c = S(t.left) ? `(${a})` : a;
647
647
  if (vt(t.operator)) return `${c} ${o}`;
648
648
  if (!t.right) return `${c} ${o} ??`;
649
649
  if (o === "BETWEEN")
650
650
  return `${c} BETWEEN ${nt(t.right, r, e, n)}`;
651
651
  if (o === "IN")
652
652
  return t.right.type === "list" ? `${c} IN ${E(t.right, r, e, n)}` : `${c} IN (${E(t.right, r, e, n)})`;
653
- const f = E(t.right, r, e, n), $ = N(t.right) ? `(${f})` : f;
653
+ const f = E(t.right, r, e, n), $ = S(t.right) ? `(${f})` : f;
654
654
  if (t.operator === "IS NOT DISTINCT FROM" && q === "expanded") {
655
655
  const l = (y) => {
656
656
  const R = E(y, r, e, n);
657
- return N(y) ? `(${R})` : R;
657
+ return S(y) ? `(${R})` : R;
658
658
  }, A = `${l(t.left)} IS NULL AND ${l(t.right)} IS NULL`;
659
659
  return `(${c} = ${$} OR (${A}))`;
660
660
  }
@@ -682,15 +682,15 @@ ${s})`;
682
682
  const { operand: o } = t;
683
683
  if (o.type === "binary" && o.operator === "IN" && ((u = o.right) == null ? void 0 : u.type) === "subquery") {
684
684
  const a = E(o.left, r, e, n);
685
- return `${N(o.left) ? `(${a})` : a} NOT IN (${E(o.right, r, e, n)})`;
685
+ return `${S(o.left) ? `(${a})` : a} NOT IN (${E(o.right, r, e, n)})`;
686
686
  }
687
687
  if (o.type === "binary" && o.operator === "BETWEEN" && o.right) {
688
688
  const a = E(o.left, r, e, n);
689
- return `${N(o.left) ? `(${a})` : a} NOT BETWEEN ${nt(o.right, r, e, n)}`;
689
+ return `${S(o.left) ? `(${a})` : a} NOT BETWEEN ${nt(o.right, r, e, n)}`;
690
690
  }
691
691
  if (o.type === "binary" && o.operator === "IS NOT DISTINCT FROM" && o.right && q === "native") {
692
692
  if (r === "mysql") return `NOT (${E(o, r, e, n)})`;
693
- const a = E(o.left, r, e, n), c = N(o.left) ? `(${a})` : a, f = E(o.right, r, e, n), $ = N(o.right) ? `(${f})` : f;
693
+ const a = E(o.left, r, e, n), c = S(o.left) ? `(${a})` : a, f = E(o.right, r, e, n), $ = S(o.right) ? `(${f})` : f;
694
694
  return `${c} IS DISTINCT FROM ${$}`;
695
695
  }
696
696
  if (o.type === "logical" || o.type === "not") {
@@ -760,12 +760,12 @@ const er = {
760
760
  cross: "CROSS JOIN"
761
761
  };
762
762
  let Ot = /* @__PURE__ */ new Map();
763
- function Nt(t, r, e) {
764
- return t.shared !== void 0 ? S(Ot.get(t.shared) ?? "??", r) : t.query ? `(
765
- ${St(t.query, r, e).replace(/^/gm, " ")}
766
- )` : S(t.table, r);
767
- }
768
763
  function St(t, r, e) {
764
+ return t.shared !== void 0 ? N(Ot.get(t.shared) ?? "??", r) : t.query ? `(
765
+ ${Nt(t.query, r, e).replace(/^/gm, " ")}
766
+ )` : N(t.table, r);
767
+ }
768
+ function Nt(t, r, e) {
769
769
  return _t(t).map((n) => W(n, r, e).join(`
770
770
  `)).join(Yt(t) && !t.all ? `
771
771
  UNION
@@ -776,20 +776,20 @@ UNION ALL
776
776
  function nr(t, r, e) {
777
777
  return t.length === 0 ? [] : [`WITH
778
778
  ${t.map((s) => m(s, () => {
779
- const i = St(s.query, r, e).replace(/^/gm, " ");
780
- return ` ${S(s.name, r)} AS (
779
+ const i = Nt(s.query, r, e).replace(/^/gm, " ");
780
+ return ` ${N(s.name, r)} AS (
781
781
  ${i}
782
782
  )`;
783
783
  })).join(`,
784
784
  `)}`];
785
785
  }
786
786
  function Rt(t, r, e) {
787
- const n = t.alias ? ` AS ${S(t.alias, r)}` : "";
788
- return `FROM ${m(t, () => `${Nt(t, r, e)}${n}`)}`;
787
+ const n = t.alias ? ` AS ${N(t.alias, r)}` : "";
788
+ return `FROM ${m(t, () => `${St(t, r, e)}${n}`)}`;
789
789
  }
790
790
  function pt(t, r, e) {
791
791
  return m(t, () => {
792
- const n = Nt(t, r, e), s = t.alias ? ` AS ${S(t.alias, r)}` : "";
792
+ const n = St(t, r, e), s = t.alias ? ` AS ${N(t.alias, r)}` : "";
793
793
  if (t.joinType === "cross") return `CROSS JOIN ${n}${s}`;
794
794
  const i = t.on ? E(t.on, r, 1, e) : "/* unconfigured */";
795
795
  return `${er[t.joinType]} ${n}${s}
@@ -799,7 +799,7 @@ function pt(t, r, e) {
799
799
  function sr(t, r, e, n = "SELECT") {
800
800
  if (t.length === 0) return `${n} ${m(t, () => "*")}`;
801
801
  const s = t.map((i) => m(i, () => {
802
- const u = E(i.expression, r, 1, e), o = i.alias ? ` AS ${S(i.alias, r)}` : "";
802
+ const u = E(i.expression, r, 1, e), o = i.alias ? ` AS ${N(i.alias, r)}` : "";
803
803
  return `${u}${o}`;
804
804
  }));
805
805
  return `${n}
@@ -875,7 +875,7 @@ function ar(t, r) {
875
875
  return "?";
876
876
  }
877
877
  }
878
- function Nr(t, r, e = {}) {
878
+ function Sr(t, r, e = {}) {
879
879
  const n = e.schema ? Tt(t, e.schema) : { query: t, params: /* @__PURE__ */ new Map() }, s = {
880
880
  values: [],
881
881
  named: new Map(Object.entries(e.values ?? {}).map(([c, f]) => {
@@ -894,7 +894,7 @@ function Nr(t, r, e = {}) {
894
894
  export {
895
895
  gr as D,
896
896
  Gt as S,
897
- Nr as a,
897
+ Sr as a,
898
898
  Or as b,
899
899
  yr as c,
900
900
  Ar as s,
@@ -161,6 +161,11 @@ export interface SuggestJoinOptions {
161
161
  * join tied to one of them is LEFT too, whatever its key: an INNER join
162
162
  * there would drop the rows the LEFT join kept. */
163
163
  leftJoined?: string[];
164
+ /** Tie it to a table reached by a step up even when joining it from
165
+ * there is a step down, as scopeQuery's paths may (JoinPathOptions). By
166
+ * default such a table is no tie, so a table findJoinPath finds no path
167
+ * to gets no join (issue 17). */
168
+ anyShape?: boolean;
164
169
  }
165
170
  /** Suggests a join type + ON condition for adding `newTable` alongside the
166
171
  * tables already in the pipeline, using the relation graph. Tied to
@@ -173,7 +178,7 @@ export interface SuggestJoinOptions {
173
178
  * an INNER join there would silently drop unpromoted sales) or the table
174
179
  * it's tied to is in `options.leftJoined`, and 'inner' otherwise. Returns
175
180
  * undefined if no relation connects `newTable` to anything already
176
- * present. */
181
+ * present, or only a step down from a table reached by a step up. */
177
182
  export declare function suggestJoin(schema: DatabaseSchema, existingTables: string[], newTable: string, options?: SuggestJoinOptions): JoinSuggestion | undefined;
178
183
  export type SchemaIssueKind = 'duplicateTable' | 'duplicateColumn' | 'unknownTable' | 'unknownColumn' | 'duplicateRelation' | 'invalidFormat';
179
184
  export interface SchemaIssue {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nongt/visql",
3
- "version": "0.10.0",
3
+ "version": "0.10.1",
4
4
  "description": "A visual SQL query editor for React: build a whole query on a node canvas, store it as JSON, turn it into SQL.",
5
5
  "keywords": [
6
6
  "sql",