trilean-sql 2.1.2 → 2.1.3
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/compile.cjs +3 -4
- package/dist/compile.d.cts +3 -4
- package/dist/compile.d.ts +3 -4
- package/dist/compile.js +3 -4
- package/dist/guard.cjs +1 -2
- package/dist/guard.d.cts +1 -2
- package/dist/guard.d.ts +1 -2
- package/dist/guard.js +1 -2
- package/dist/portable-pattern.cjs +2 -4
- package/dist/portable-pattern.d.cts +2 -4
- package/dist/portable-pattern.d.ts +2 -4
- package/dist/portable-pattern.js +2 -4
- package/package.json +2 -2
package/dist/compile.cjs
CHANGED
|
@@ -144,10 +144,9 @@ function compilePredicate(node, context) {
|
|
|
144
144
|
* Three-valued logic is not reimplemented on top of SQL; it is delegated to it. SQL's `AND`, `OR` and `NOT` over `TRUE`/`FALSE`/`NULL` are Kleene's strong three-valued tables, which are the same tables trilean's own `combineAnd`, `combineOr` and `not` implement, and a comparison against a NULL column yields `NULL` exactly where the evaluator would have returned `indeterminate` from an unresolved reference. A row excluded by `WHERE` because its condition was unknown is therefore excluded for the same reason, and by the same rule, as a subject the evaluator declines to judge. No indeterminacy column, sentinel value or `CASE` scaffolding is emitted, because none is needed.
|
|
145
145
|
*
|
|
146
146
|
* Every caller-supplied literal becomes a bind parameter. Nothing but structure, operators, and quoted column identifiers is ever written into the returned `sql`.
|
|
147
|
-
*
|
|
148
|
-
* @throws
|
|
149
|
-
* @throws
|
|
150
|
-
* @throws {InvalidColumnError} if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
147
|
+
* @throws `UnknownDialectError` if `options.dialect` names a dialect this version does not implement.
|
|
148
|
+
* @throws `UnsupportedNodeError` if any node in the tree is one this compiler will not translate -- see `findUnpushableNodeKind`, which this runs first and which a caller can run itself to choose between pushdown and in-process evaluation without provoking an exception.
|
|
149
|
+
* @throws `InvalidColumnError` if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
151
150
|
*/
|
|
152
151
|
function compilePredicateNode(node, options) {
|
|
153
152
|
require_options.assertImplementedDialect(options.dialect);
|
package/dist/compile.d.cts
CHANGED
|
@@ -7,10 +7,9 @@ import { PredicateNode } from "trilean";
|
|
|
7
7
|
* Three-valued logic is not reimplemented on top of SQL; it is delegated to it. SQL's `AND`, `OR` and `NOT` over `TRUE`/`FALSE`/`NULL` are Kleene's strong three-valued tables, which are the same tables trilean's own `combineAnd`, `combineOr` and `not` implement, and a comparison against a NULL column yields `NULL` exactly where the evaluator would have returned `indeterminate` from an unresolved reference. A row excluded by `WHERE` because its condition was unknown is therefore excluded for the same reason, and by the same rule, as a subject the evaluator declines to judge. No indeterminacy column, sentinel value or `CASE` scaffolding is emitted, because none is needed.
|
|
8
8
|
*
|
|
9
9
|
* Every caller-supplied literal becomes a bind parameter. Nothing but structure, operators, and quoted column identifiers is ever written into the returned `sql`.
|
|
10
|
-
*
|
|
11
|
-
* @throws
|
|
12
|
-
* @throws
|
|
13
|
-
* @throws {InvalidColumnError} if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
10
|
+
* @throws `UnknownDialectError` if `options.dialect` names a dialect this version does not implement.
|
|
11
|
+
* @throws `UnsupportedNodeError` if any node in the tree is one this compiler will not translate -- see `findUnpushableNodeKind`, which this runs first and which a caller can run itself to choose between pushdown and in-process evaluation without provoking an exception.
|
|
12
|
+
* @throws `InvalidColumnError` if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
14
13
|
*/
|
|
15
14
|
declare function compilePredicateNode(node: PredicateNode, options: Readonly<SqlCompileOptions>): CompiledSql;
|
|
16
15
|
//#endregion
|
package/dist/compile.d.ts
CHANGED
|
@@ -7,10 +7,9 @@ import { PredicateNode } from "trilean";
|
|
|
7
7
|
* Three-valued logic is not reimplemented on top of SQL; it is delegated to it. SQL's `AND`, `OR` and `NOT` over `TRUE`/`FALSE`/`NULL` are Kleene's strong three-valued tables, which are the same tables trilean's own `combineAnd`, `combineOr` and `not` implement, and a comparison against a NULL column yields `NULL` exactly where the evaluator would have returned `indeterminate` from an unresolved reference. A row excluded by `WHERE` because its condition was unknown is therefore excluded for the same reason, and by the same rule, as a subject the evaluator declines to judge. No indeterminacy column, sentinel value or `CASE` scaffolding is emitted, because none is needed.
|
|
8
8
|
*
|
|
9
9
|
* Every caller-supplied literal becomes a bind parameter. Nothing but structure, operators, and quoted column identifiers is ever written into the returned `sql`.
|
|
10
|
-
*
|
|
11
|
-
* @throws
|
|
12
|
-
* @throws
|
|
13
|
-
* @throws {InvalidColumnError} if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
10
|
+
* @throws `UnknownDialectError` if `options.dialect` names a dialect this version does not implement.
|
|
11
|
+
* @throws `UnsupportedNodeError` if any node in the tree is one this compiler will not translate -- see `findUnpushableNodeKind`, which this runs first and which a caller can run itself to choose between pushdown and in-process evaluation without provoking an exception.
|
|
12
|
+
* @throws `InvalidColumnError` if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
14
13
|
*/
|
|
15
14
|
declare function compilePredicateNode(node: PredicateNode, options: Readonly<SqlCompileOptions>): CompiledSql;
|
|
16
15
|
//#endregion
|
package/dist/compile.js
CHANGED
|
@@ -143,10 +143,9 @@ function compilePredicate(node, context) {
|
|
|
143
143
|
* Three-valued logic is not reimplemented on top of SQL; it is delegated to it. SQL's `AND`, `OR` and `NOT` over `TRUE`/`FALSE`/`NULL` are Kleene's strong three-valued tables, which are the same tables trilean's own `combineAnd`, `combineOr` and `not` implement, and a comparison against a NULL column yields `NULL` exactly where the evaluator would have returned `indeterminate` from an unresolved reference. A row excluded by `WHERE` because its condition was unknown is therefore excluded for the same reason, and by the same rule, as a subject the evaluator declines to judge. No indeterminacy column, sentinel value or `CASE` scaffolding is emitted, because none is needed.
|
|
144
144
|
*
|
|
145
145
|
* Every caller-supplied literal becomes a bind parameter. Nothing but structure, operators, and quoted column identifiers is ever written into the returned `sql`.
|
|
146
|
-
*
|
|
147
|
-
* @throws
|
|
148
|
-
* @throws
|
|
149
|
-
* @throws {InvalidColumnError} if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
146
|
+
* @throws `UnknownDialectError` if `options.dialect` names a dialect this version does not implement.
|
|
147
|
+
* @throws `UnsupportedNodeError` if any node in the tree is one this compiler will not translate -- see `findUnpushableNodeKind`, which this runs first and which a caller can run itself to choose between pushdown and in-process evaluation without provoking an exception.
|
|
148
|
+
* @throws `InvalidColumnError` if `columnFor` returns a column that cannot be rendered as an identifier.
|
|
150
149
|
*/
|
|
151
150
|
function compilePredicateNode(node, options) {
|
|
152
151
|
assertImplementedDialect(options.dialect);
|
package/dist/guard.cjs
CHANGED
|
@@ -282,8 +282,7 @@ function findUnpushablePredicate(node, path, options, divergence) {
|
|
|
282
282
|
* Passing `options` widens the check: without them the walk is purely structural, and with them it also applies the operand-kind rules that depend on each mapped column's declared `paramType` (and therefore calls `columnFor`).
|
|
283
283
|
*
|
|
284
284
|
* Which nodes are refused does not depend on the dialect -- every divergence refused here is real in both -- so a structural walk given no `options` refuses exactly what a walk given them would. What `options` also settles is which engine each `reason` describes; with none to read a dialect from, the reasons describe PostgreSQL, the dialect these refusals were first derived against.
|
|
285
|
-
*
|
|
286
|
-
* @throws {UnknownDialectError} if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
285
|
+
* @throws `UnknownDialectError` if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
287
286
|
*/
|
|
288
287
|
function findUnpushableNodeKind(node, options) {
|
|
289
288
|
const dialect = options?.dialect ?? "postgres";
|
package/dist/guard.d.cts
CHANGED
|
@@ -18,8 +18,7 @@ interface UnpushableNode {
|
|
|
18
18
|
* Passing `options` widens the check: without them the walk is purely structural, and with them it also applies the operand-kind rules that depend on each mapped column's declared `paramType` (and therefore calls `columnFor`).
|
|
19
19
|
*
|
|
20
20
|
* Which nodes are refused does not depend on the dialect -- every divergence refused here is real in both -- so a structural walk given no `options` refuses exactly what a walk given them would. What `options` also settles is which engine each `reason` describes; with none to read a dialect from, the reasons describe PostgreSQL, the dialect these refusals were first derived against.
|
|
21
|
-
*
|
|
22
|
-
* @throws {UnknownDialectError} if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
21
|
+
* @throws `UnknownDialectError` if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
23
22
|
*/
|
|
24
23
|
declare function findUnpushableNodeKind(node: PredicateNode, options?: SqlCompileOptions): UnpushableNode | undefined;
|
|
25
24
|
//#endregion
|
package/dist/guard.d.ts
CHANGED
|
@@ -18,8 +18,7 @@ interface UnpushableNode {
|
|
|
18
18
|
* Passing `options` widens the check: without them the walk is purely structural, and with them it also applies the operand-kind rules that depend on each mapped column's declared `paramType` (and therefore calls `columnFor`).
|
|
19
19
|
*
|
|
20
20
|
* Which nodes are refused does not depend on the dialect -- every divergence refused here is real in both -- so a structural walk given no `options` refuses exactly what a walk given them would. What `options` also settles is which engine each `reason` describes; with none to read a dialect from, the reasons describe PostgreSQL, the dialect these refusals were first derived against.
|
|
21
|
-
*
|
|
22
|
-
* @throws {UnknownDialectError} if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
21
|
+
* @throws `UnknownDialectError` if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
23
22
|
*/
|
|
24
23
|
declare function findUnpushableNodeKind(node: PredicateNode, options?: SqlCompileOptions): UnpushableNode | undefined;
|
|
25
24
|
//#endregion
|
package/dist/guard.js
CHANGED
|
@@ -281,8 +281,7 @@ function findUnpushablePredicate(node, path, options, divergence) {
|
|
|
281
281
|
* Passing `options` widens the check: without them the walk is purely structural, and with them it also applies the operand-kind rules that depend on each mapped column's declared `paramType` (and therefore calls `columnFor`).
|
|
282
282
|
*
|
|
283
283
|
* Which nodes are refused does not depend on the dialect -- every divergence refused here is real in both -- so a structural walk given no `options` refuses exactly what a walk given them would. What `options` also settles is which engine each `reason` describes; with none to read a dialect from, the reasons describe PostgreSQL, the dialect these refusals were first derived against.
|
|
284
|
-
*
|
|
285
|
-
* @throws {UnknownDialectError} if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
284
|
+
* @throws `UnknownDialectError` if `options` names a dialect this version does not implement. Reporting a tree as pushable is a promise that `compilePredicateNode` will compile it, and under a dialect that does not exist it cannot -- so this is refused here rather than left to surface from the compiler, which is the one caller this function's answer is for.
|
|
286
285
|
*/
|
|
287
286
|
function findUnpushableNodeKind(node, options) {
|
|
288
287
|
const dialect = options?.dialect ?? "postgres";
|
|
@@ -60,8 +60,7 @@ function renderPostgresSubcomponent(node) {
|
|
|
60
60
|
* Translates a `trilean-regex` AST into PostgreSQL's own Advanced Regular Expression syntax, for binding as the pattern argument to `~`/`!~`.
|
|
61
61
|
*
|
|
62
62
|
* Every construct this grammar accepts translates structurally, `.` included: measured directly against a real PostgreSQL 17 server (see the "PostgreSQL's own engine treats '.' as matching a newline" case in `test/integration/postgres.test.ts`), PostgreSQL's `.` matches a newline by default in the mode this compiler's `~`/`!~` operators run under -- the same as this grammar's own `.` (see trilean-regex's README) -- so no rewriting is needed here. (PostgreSQL's own prose documentation reads, in isolation, as though newline-sensitive matching were the default; it is not the one this operator uses, and the fact was confirmed against the real server rather than trusted from the prose alone -- see the "Verify this assumption" principle this compiler otherwise applies to every other construct too.)
|
|
63
|
-
*
|
|
64
|
-
* @throws {PortablePatternUnsupportedError} if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
63
|
+
* @throws `PortablePatternUnsupportedError` if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
65
64
|
*/
|
|
66
65
|
function renderPostgresPattern(node) {
|
|
67
66
|
switch (node.kind) {
|
|
@@ -139,8 +138,7 @@ function planGlobBody(node) {
|
|
|
139
138
|
}
|
|
140
139
|
/**
|
|
141
140
|
* Translates a `trilean-regex` AST into a `GLOB` pattern, for binding as `GLOB`/`NOT GLOB`'s right-hand argument. See the "reachable subset" doc comment above for exactly what this does and does not translate.
|
|
142
|
-
*
|
|
143
|
-
* @throws {PortablePatternUnsupportedError} if `node` uses any construct outside the reachable subset.
|
|
141
|
+
* @throws `PortablePatternUnsupportedError` if `node` uses any construct outside the reachable subset.
|
|
144
142
|
*/
|
|
145
143
|
function renderSqliteGlobPattern(node) {
|
|
146
144
|
const plan = planGlobBody(node);
|
|
@@ -8,14 +8,12 @@ declare class PortablePatternUnsupportedError extends Error {}
|
|
|
8
8
|
* Translates a `trilean-regex` AST into PostgreSQL's own Advanced Regular Expression syntax, for binding as the pattern argument to `~`/`!~`.
|
|
9
9
|
*
|
|
10
10
|
* Every construct this grammar accepts translates structurally, `.` included: measured directly against a real PostgreSQL 17 server (see the "PostgreSQL's own engine treats '.' as matching a newline" case in `test/integration/postgres.test.ts`), PostgreSQL's `.` matches a newline by default in the mode this compiler's `~`/`!~` operators run under -- the same as this grammar's own `.` (see trilean-regex's README) -- so no rewriting is needed here. (PostgreSQL's own prose documentation reads, in isolation, as though newline-sensitive matching were the default; it is not the one this operator uses, and the fact was confirmed against the real server rather than trusted from the prose alone -- see the "Verify this assumption" principle this compiler otherwise applies to every other construct too.)
|
|
11
|
-
*
|
|
12
|
-
* @throws {PortablePatternUnsupportedError} if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
11
|
+
* @throws `PortablePatternUnsupportedError` if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
13
12
|
*/
|
|
14
13
|
declare function renderPostgresPattern(node: RegexNode): string;
|
|
15
14
|
/**
|
|
16
15
|
* Translates a `trilean-regex` AST into a `GLOB` pattern, for binding as `GLOB`/`NOT GLOB`'s right-hand argument. See the "reachable subset" doc comment above for exactly what this does and does not translate.
|
|
17
|
-
*
|
|
18
|
-
* @throws {PortablePatternUnsupportedError} if `node` uses any construct outside the reachable subset.
|
|
16
|
+
* @throws `PortablePatternUnsupportedError` if `node` uses any construct outside the reachable subset.
|
|
19
17
|
*/
|
|
20
18
|
declare function renderSqliteGlobPattern(node: RegexNode): string;
|
|
21
19
|
//#endregion
|
|
@@ -8,14 +8,12 @@ declare class PortablePatternUnsupportedError extends Error {}
|
|
|
8
8
|
* Translates a `trilean-regex` AST into PostgreSQL's own Advanced Regular Expression syntax, for binding as the pattern argument to `~`/`!~`.
|
|
9
9
|
*
|
|
10
10
|
* Every construct this grammar accepts translates structurally, `.` included: measured directly against a real PostgreSQL 17 server (see the "PostgreSQL's own engine treats '.' as matching a newline" case in `test/integration/postgres.test.ts`), PostgreSQL's `.` matches a newline by default in the mode this compiler's `~`/`!~` operators run under -- the same as this grammar's own `.` (see trilean-regex's README) -- so no rewriting is needed here. (PostgreSQL's own prose documentation reads, in isolation, as though newline-sensitive matching were the default; it is not the one this operator uses, and the fact was confirmed against the real server rather than trusted from the prose alone -- see the "Verify this assumption" principle this compiler otherwise applies to every other construct too.)
|
|
11
|
-
*
|
|
12
|
-
* @throws {PortablePatternUnsupportedError} if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
11
|
+
* @throws `PortablePatternUnsupportedError` if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
13
12
|
*/
|
|
14
13
|
declare function renderPostgresPattern(node: RegexNode): string;
|
|
15
14
|
/**
|
|
16
15
|
* Translates a `trilean-regex` AST into a `GLOB` pattern, for binding as `GLOB`/`NOT GLOB`'s right-hand argument. See the "reachable subset" doc comment above for exactly what this does and does not translate.
|
|
17
|
-
*
|
|
18
|
-
* @throws {PortablePatternUnsupportedError} if `node` uses any construct outside the reachable subset.
|
|
16
|
+
* @throws `PortablePatternUnsupportedError` if `node` uses any construct outside the reachable subset.
|
|
19
17
|
*/
|
|
20
18
|
declare function renderSqliteGlobPattern(node: RegexNode): string;
|
|
21
19
|
//#endregion
|
package/dist/portable-pattern.js
CHANGED
|
@@ -59,8 +59,7 @@ function renderPostgresSubcomponent(node) {
|
|
|
59
59
|
* Translates a `trilean-regex` AST into PostgreSQL's own Advanced Regular Expression syntax, for binding as the pattern argument to `~`/`!~`.
|
|
60
60
|
*
|
|
61
61
|
* Every construct this grammar accepts translates structurally, `.` included: measured directly against a real PostgreSQL 17 server (see the "PostgreSQL's own engine treats '.' as matching a newline" case in `test/integration/postgres.test.ts`), PostgreSQL's `.` matches a newline by default in the mode this compiler's `~`/`!~` operators run under -- the same as this grammar's own `.` (see trilean-regex's README) -- so no rewriting is needed here. (PostgreSQL's own prose documentation reads, in isolation, as though newline-sensitive matching were the default; it is not the one this operator uses, and the fact was confirmed against the real server rather than trusted from the prose alone -- see the "Verify this assumption" principle this compiler otherwise applies to every other construct too.)
|
|
62
|
-
*
|
|
63
|
-
* @throws {PortablePatternUnsupportedError} if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
62
|
+
* @throws `PortablePatternUnsupportedError` if a bounded repetition exceeds PostgreSQL's own 0-255 bound limit.
|
|
64
63
|
*/
|
|
65
64
|
function renderPostgresPattern(node) {
|
|
66
65
|
switch (node.kind) {
|
|
@@ -138,8 +137,7 @@ function planGlobBody(node) {
|
|
|
138
137
|
}
|
|
139
138
|
/**
|
|
140
139
|
* Translates a `trilean-regex` AST into a `GLOB` pattern, for binding as `GLOB`/`NOT GLOB`'s right-hand argument. See the "reachable subset" doc comment above for exactly what this does and does not translate.
|
|
141
|
-
*
|
|
142
|
-
* @throws {PortablePatternUnsupportedError} if `node` uses any construct outside the reachable subset.
|
|
140
|
+
* @throws `PortablePatternUnsupportedError` if `node` uses any construct outside the reachable subset.
|
|
143
141
|
*/
|
|
144
142
|
function renderSqliteGlobPattern(node) {
|
|
145
143
|
const plan = planGlobBody(node);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "trilean-sql",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.3",
|
|
4
4
|
"description": "Compiles a trilean predicate tree into a parameterised SQL WHERE fragment, pushing three-valued logic down onto the database's own NULL propagation instead of evaluating it in process.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"repository": {
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@arethetypeswrong/cli": "^0.18.5",
|
|
84
84
|
"@electric-sql/pglite": "^0.5.8",
|
|
85
|
-
"@exadev/eslint-config": "
|
|
85
|
+
"@exadev/eslint-config": "2.12.1",
|
|
86
86
|
"@testcontainers/postgresql": "^12.1.0",
|
|
87
87
|
"@types/better-sqlite3": "^9.6.0",
|
|
88
88
|
"@types/node": "^26.4.0",
|