@nongt/visql-core 0.13.0 → 0.14.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.
@@ -28,6 +28,10 @@ export interface TableColumn {
28
28
  label: string;
29
29
  type: DatabaseColumnType;
30
30
  nullable?: boolean;
31
+ /** What the column means, for whoever builds a query: a line under its
32
+ * label in the field picker (search matches it too), and shown on
33
+ * hovering it once picked. E.g. that NULL means "not specified". */
34
+ description?: string;
31
35
  /** A fixed set of allowed values (an enum, a status…). Values compared
32
36
  * against this column are then picked from a dropdown instead of typed. */
33
37
  options?: ColumnOption[];
@@ -56,14 +60,28 @@ export interface ColumnOption {
56
60
  * `toTable.toColumn` — so the `from` side is the "many" side (e.g.
57
61
  * sale_transaction.product_id → product.id). The reverse direction
58
62
  * (product → its sales) is derived wherever it's needed; never declare it as
59
- * a second entry (validateSchema reports that as a duplicate). Single-column
60
- * keys only. */
63
+ * a second entry (validateSchema reports that as a duplicate). A key of
64
+ * several columns lists the others in `also`. */
61
65
  export interface Relation {
62
66
  fromTable: string;
63
67
  fromColumn: string;
64
68
  toTable: string;
65
69
  toColumn: string;
70
+ /** The key's other columns, when it's more than one (issue 44): a sale
71
+ * line referencing its sale by `store_id` and `sale_no`. A join's ON
72
+ * then matches every pair, ANDed. */
73
+ also?: {
74
+ fromColumn: string;
75
+ toColumn: string;
76
+ }[];
66
77
  }
78
+ /** Every column pair of a relation's key, `fromColumn`/`toColumn` first. */
79
+ export declare function keyColumns(r: Relation): {
80
+ fromColumn: string;
81
+ toColumn: string;
82
+ }[];
83
+ /** `conditions` ANDed: the one alone, else a group of them. */
84
+ export declare function allOf(conditions: ExpressionNode[]): ExpressionNode;
67
85
  /** Everything the builder knows about the database it's building queries for —
68
86
  * supplied by the host app (PipelineEditor's `schema` prop, distributed to
69
87
  * components via SchemaContext) rather than baked into this package. Every
@@ -173,8 +191,8 @@ export interface SuggestJoinOptions {
173
191
  * order (base table first, then join-insertion order) and the first
174
192
  * relation found wins, so the result is deterministic. A table with
175
193
  * `passThrough: false` is tried only for itself, or when the query has no
176
- * other table (startsOf). `joinType` is 'left' when the relation's FK
177
- * column (`fromColumn`) is nullable (e.g. sale_transaction.promotion_id:
194
+ * other table (startsOf). `joinType` is 'left' when one of the relation's FK
195
+ * columns (`fromColumn`, `also`) is nullable (e.g. sale_transaction.promotion_id:
178
196
  * an INNER join there would silently drop unpromoted sales) or the table
179
197
  * it's tied to is in `options.leftJoined`, and 'inner' otherwise. Returns
180
198
  * undefined if no relation connects `newTable` to anything already
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nongt/visql-core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "The query logic of @nongt/visql, for a backend: load, check, scope, write SQL, import SQL, read query plans. No React, no dependencies.",
5
5
  "keywords": [
6
6
  "sql",