@ignisia/sql 0.3.0 → 0.4.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 +1 -1
- package/dist/cjs/column/index.js +2 -9
- package/dist/cjs/database/alter.d.cts +2 -2
- package/dist/cjs/database/column.d.cts +2 -2
- package/dist/cjs/database/contract.d.cts +2 -2
- package/dist/cjs/database/index.d.cts +2 -2
- package/dist/cjs/database/index.js +1 -1
- package/dist/cjs/database/table.d.cts +2 -2
- package/dist/cjs/database/types.d.cts +1 -1
- package/dist/cjs/database/wrapper.d.cts +3 -3
- package/dist/cjs/database/wrapper.js +1 -17
- package/dist/cjs/{index-2jl8MRfX.d.cts → index-BjgeY76W.d.cts} +2 -2
- package/dist/cjs/{index-CnQVnCEI.d.cts → index-K07efKgt.d.cts} +194 -86
- package/dist/cjs/index.d.cts +2 -2
- package/dist/cjs/migration/index.d.cts +2 -2
- package/dist/cjs/migration/type.d.cts +2 -2
- package/dist/cjs/query/ast.d.cts +8 -0
- package/dist/cjs/query/ast.js +2 -0
- package/dist/cjs/query/builder.d.cts +5 -5
- package/dist/cjs/query/builder.js +8 -10
- package/dist/cjs/query/compiler.d.cts +13 -0
- package/dist/cjs/query/compiler.js +114 -0
- package/dist/cjs/query/condition/common.d.cts +46 -0
- package/dist/cjs/query/condition/common.js +50 -0
- package/dist/cjs/query/condition/core.d.cts +8 -0
- package/dist/cjs/query/condition/core.js +91 -0
- package/dist/cjs/query/condition/index.d.cts +10 -0
- package/dist/cjs/query/condition/index.js +26 -0
- package/dist/cjs/query/condition/not.d.cts +46 -0
- package/dist/cjs/query/condition/not.js +51 -0
- package/dist/cjs/query/constants.d.cts +31 -6
- package/dist/cjs/query/constants.js +30 -5
- package/dist/cjs/query/contract.d.cts +2 -2
- package/dist/cjs/query/explain.d.cts +12 -0
- package/dist/cjs/query/explain.js +65 -0
- package/dist/cjs/query/helper.d.cts +3 -3
- package/dist/cjs/query/helper.js +1 -5
- package/dist/cjs/query/index.d.cts +4 -4
- package/dist/cjs/query/index.js +57 -72
- package/dist/cjs/query/join.d.cts +19 -7
- package/dist/cjs/query/join.js +46 -9
- package/dist/cjs/query/sql.d.cts +6 -4
- package/dist/cjs/query/sql.js +64 -25
- package/dist/cjs/query/types.d.cts +2 -2
- package/dist/cjs/query/utilities.d.cts +7 -8
- package/dist/cjs/query/utilities.js +21 -66
- package/dist/cjs/table/index.d.cts +3 -3
- package/dist/cjs/table/types.d.cts +2 -2
- package/dist/cjs/table/utilities.d.cts +2 -2
- package/dist/cjs/types.d.cts +5 -1
- package/dist/cjs/utilities.d.cts +2 -1
- package/dist/cjs/utilities.js +22 -0
- package/dist/esm/column/index.js +3 -10
- package/dist/esm/database/alter.d.ts +2 -2
- package/dist/esm/database/column.d.ts +2 -2
- package/dist/esm/database/contract.d.ts +2 -2
- package/dist/esm/database/index.d.ts +2 -2
- package/dist/esm/database/index.js +2 -2
- package/dist/esm/database/table.d.ts +2 -2
- package/dist/esm/database/types.d.ts +1 -1
- package/dist/esm/database/wrapper.d.ts +3 -3
- package/dist/esm/database/wrapper.js +1 -17
- package/dist/esm/{index-BXOAxB_h.d.ts → index-B4y4GiNB.d.ts} +2 -2
- package/dist/esm/{index-BdpoD4zk.d.ts → index-CARBkj9h.d.ts} +194 -86
- package/dist/esm/index.d.ts +2 -2
- package/dist/esm/migration/index.d.ts +2 -2
- package/dist/esm/migration/type.d.ts +2 -2
- package/dist/esm/query/ast.d.ts +8 -0
- package/dist/esm/query/ast.js +1 -0
- package/dist/esm/query/builder.d.ts +5 -5
- package/dist/esm/query/builder.js +8 -10
- package/dist/esm/query/compiler.d.ts +13 -0
- package/dist/esm/query/compiler.js +112 -0
- package/dist/esm/query/condition/common.d.ts +46 -0
- package/dist/esm/query/condition/common.js +45 -0
- package/dist/esm/query/condition/core.d.ts +8 -0
- package/dist/esm/query/condition/core.js +89 -0
- package/dist/esm/query/condition/index.d.ts +10 -0
- package/dist/esm/query/condition/index.js +3 -0
- package/dist/esm/query/condition/not.d.ts +46 -0
- package/dist/esm/query/condition/not.js +46 -0
- package/dist/esm/query/constants.d.ts +31 -6
- package/dist/esm/query/constants.js +28 -6
- package/dist/esm/query/contract.d.ts +2 -2
- package/dist/esm/query/explain.d.ts +12 -0
- package/dist/esm/query/explain.js +64 -0
- package/dist/esm/query/helper.d.ts +3 -3
- package/dist/esm/query/helper.js +3 -6
- package/dist/esm/query/index.d.ts +4 -4
- package/dist/esm/query/index.js +60 -75
- package/dist/esm/query/join.d.ts +19 -7
- package/dist/esm/query/join.js +45 -9
- package/dist/esm/query/sql.d.ts +6 -4
- package/dist/esm/query/sql.js +64 -27
- package/dist/esm/query/types.d.ts +2 -2
- package/dist/esm/query/utilities.d.ts +7 -8
- package/dist/esm/query/utilities.js +22 -66
- package/dist/esm/table/index.d.ts +3 -3
- package/dist/esm/table/types.d.ts +2 -2
- package/dist/esm/table/utilities.d.ts +2 -2
- package/dist/esm/types.d.ts +5 -1
- package/dist/esm/utilities.d.ts +2 -1
- package/dist/esm/utilities.js +22 -1
- package/package.json +11 -5
- package/dist/cjs/query/condition.d.cts +0 -8
- package/dist/cjs/query/condition.js +0 -109
- package/dist/esm/query/condition.d.ts +0 -8
- package/dist/esm/query/condition.js +0 -101
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants$1 = require('../table/constants');
|
|
4
|
+
var constants = require('./constants');
|
|
5
|
+
|
|
6
|
+
function compileComparison(dialect, node, params) {
|
|
7
|
+
const column = node.column;
|
|
8
|
+
if (node.operator === constants.AcceptedOperator.BETWEEN || node.operator === constants.AcceptedOperator.IN) {
|
|
9
|
+
params.push(...node.values);
|
|
10
|
+
} else if (node.operator !== constants.AcceptedOperator.IS_NULL && "value" in node) {
|
|
11
|
+
params.push(node.value);
|
|
12
|
+
}
|
|
13
|
+
switch (node.operator) {
|
|
14
|
+
case constants.AcceptedOperator.EQ:
|
|
15
|
+
return `${column} = ?`;
|
|
16
|
+
case constants.AcceptedOperator.NE:
|
|
17
|
+
return `${column} != ?`;
|
|
18
|
+
case constants.AcceptedOperator.GT:
|
|
19
|
+
return `${column} > ?`;
|
|
20
|
+
case constants.AcceptedOperator.LT:
|
|
21
|
+
return `${column} < ?`;
|
|
22
|
+
case constants.AcceptedOperator.GTE:
|
|
23
|
+
return `${column} >= ?`;
|
|
24
|
+
case constants.AcceptedOperator.LTE:
|
|
25
|
+
return `${column} <= ?`;
|
|
26
|
+
case constants.AcceptedOperator.IN:
|
|
27
|
+
return `${column} IN (${node.values.map(() => "?").join(", ")})`;
|
|
28
|
+
case constants.AcceptedOperator.LIKE:
|
|
29
|
+
return `${column} LIKE ?`;
|
|
30
|
+
case constants.AcceptedOperator.ILIKE:
|
|
31
|
+
if (dialect === constants$1.Dialect.POSTGRES) {
|
|
32
|
+
return `${column} ILIKE ?`;
|
|
33
|
+
}
|
|
34
|
+
return `LOWER(${column}) LIKE LOWER(?)`;
|
|
35
|
+
case constants.AcceptedOperator.IS_NULL:
|
|
36
|
+
return `${column} IS NULL`;
|
|
37
|
+
case constants.AcceptedOperator.BETWEEN:
|
|
38
|
+
return `${column} BETWEEN ? AND ?`;
|
|
39
|
+
case constants.AcceptedOperator.STARTS_WITH:
|
|
40
|
+
return `${column} LIKE ?`;
|
|
41
|
+
case constants.AcceptedOperator.ENDS_WITH:
|
|
42
|
+
return `${column} LIKE ?`;
|
|
43
|
+
case constants.AcceptedOperator.REG_EXP: {
|
|
44
|
+
switch (dialect) {
|
|
45
|
+
case constants$1.Dialect.POSTGRES:
|
|
46
|
+
return `${column} ~ ?`;
|
|
47
|
+
case constants$1.Dialect.MYSQL:
|
|
48
|
+
return `${column} REGEXP ?`;
|
|
49
|
+
case constants$1.Dialect.SQLITE:
|
|
50
|
+
return `${column} GLOB ?`;
|
|
51
|
+
default:
|
|
52
|
+
throw new Error("Operator not supported");
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
case constants.AcceptedOperator.RLIKE: {
|
|
56
|
+
switch (dialect) {
|
|
57
|
+
case constants$1.Dialect.POSTGRES:
|
|
58
|
+
return `${column} ~* ?`;
|
|
59
|
+
case constants$1.Dialect.MYSQL:
|
|
60
|
+
return `${column} RLIKE ?`;
|
|
61
|
+
case constants$1.Dialect.SQLITE:
|
|
62
|
+
return `${column} GLOB ?`;
|
|
63
|
+
default:
|
|
64
|
+
throw new Error("Operator not supported");
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
default:
|
|
68
|
+
throw new Error("Invalid operator");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
function compileNot(dialect, node, params) {
|
|
72
|
+
const inner = compileAst(dialect, node.child, params);
|
|
73
|
+
return `NOT (${inner})`;
|
|
74
|
+
}
|
|
75
|
+
function compileGroup(dialect, node, params) {
|
|
76
|
+
if (!node.children.length) {
|
|
77
|
+
return "";
|
|
78
|
+
}
|
|
79
|
+
const compiled = node.children.map(
|
|
80
|
+
(child) => compileAst(dialect, child, params)
|
|
81
|
+
);
|
|
82
|
+
return `(${compiled.join(` ${node.operator} `)})`;
|
|
83
|
+
}
|
|
84
|
+
function compileAst(dialect, node, params) {
|
|
85
|
+
switch (node.type) {
|
|
86
|
+
case constants.AstType.COMPARISON:
|
|
87
|
+
return compileComparison(dialect, node, params);
|
|
88
|
+
case constants.AstType.GROUP:
|
|
89
|
+
return compileGroup(dialect, node, params);
|
|
90
|
+
case constants.AstType.NOT:
|
|
91
|
+
return compileNot(dialect, node, params);
|
|
92
|
+
default:
|
|
93
|
+
throw new Error(`Unknown AST node type`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function compileJoin(dialect, join, params) {
|
|
97
|
+
const table = join.table.name;
|
|
98
|
+
const alias = join.alias;
|
|
99
|
+
if (join.join === constants.AcceptedJoin.CROSS || join.join === constants.AcceptedJoin.NATURAL) {
|
|
100
|
+
return `${join.join} JOIN ${table} AS ${alias}`;
|
|
101
|
+
}
|
|
102
|
+
if (!join.on) {
|
|
103
|
+
throw new Error(`${join.join} join requires ON condition`);
|
|
104
|
+
}
|
|
105
|
+
const onSql = compileAst(
|
|
106
|
+
dialect,
|
|
107
|
+
join.on,
|
|
108
|
+
params
|
|
109
|
+
);
|
|
110
|
+
return `${join.join} JOIN ${table} AS ${alias} ON ${onSql}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.compileAst = compileAst;
|
|
114
|
+
exports.compileJoin = compileJoin;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { T as Table, Q as QueryDefinition, C as ColumnSelector, S as StrictColumnSelector, W as WhereValue, c as QueryBuilder, e as QueryTransformerContract, f as QueryConditionContract, G as GroupNode } from '../../index-K07efKgt.cjs';
|
|
2
|
+
import { Column } from '../../column/index.cjs';
|
|
3
|
+
import { AcceptedOperator } from '../constants.cjs';
|
|
4
|
+
import 'bun';
|
|
5
|
+
import '../../types.cjs';
|
|
6
|
+
import '../../column/constants.cjs';
|
|
7
|
+
import '../../table/constants.cjs';
|
|
8
|
+
import '../../column/types.cjs';
|
|
9
|
+
|
|
10
|
+
declare function where<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, ColName extends StrictAllowedColumn, Col extends ColName extends `${infer TableAlias}.${infer TableColumn}` ? TableAlias extends Alias ? TableRef['columns'][TableColumn] : JoinedTables[TableAlias]['columns'][TableColumn] : never, Operator extends AcceptedOperator, Value extends WhereValue<Col>[Operator]>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, column: ColName, operator: Operator, value?: Value): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
11
|
+
where: string[];
|
|
12
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
13
|
+
where: string[];
|
|
14
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
15
|
+
where: string[];
|
|
16
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
17
|
+
declare function or<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, ColName extends StrictAllowedColumn, Col extends ColName extends `${infer TableAlias}.${infer TableColumn}` ? TableAlias extends Alias ? TableRef['columns'][TableColumn] : JoinedTables[TableAlias]['columns'][TableColumn] : never, Operator extends AcceptedOperator, Value extends WhereValue<Col>[Operator]>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, column: ColName, operator: Operator, value?: Value): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
18
|
+
where: string[];
|
|
19
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
20
|
+
where: string[];
|
|
21
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
22
|
+
where: string[];
|
|
23
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
24
|
+
declare function having<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, ColName extends StrictAllowedColumn, Col extends ColName extends `${infer TableAlias}.${infer TableColumn}` ? TableAlias extends Alias ? TableRef['columns'][TableColumn] : JoinedTables[TableAlias]['columns'][TableColumn] : never, Operator extends AcceptedOperator, Value extends WhereValue<Col>[Operator]>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, column: ColName, operator: Operator, value: Value): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "having"> & {
|
|
25
|
+
having: string[];
|
|
26
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "having"> & {
|
|
27
|
+
having: string[];
|
|
28
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "having"> & {
|
|
29
|
+
having: string[];
|
|
30
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
31
|
+
declare function whereGroup<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, callback: (q: QueryBuilder<Alias, TableRef, JoinedTables>) => QueryBuilder<Alias, TableRef, JoinedTables>): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
32
|
+
where: GroupNode;
|
|
33
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
34
|
+
where: GroupNode;
|
|
35
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
36
|
+
where: GroupNode;
|
|
37
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
38
|
+
declare function orGroup<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, callback: (q: QueryBuilder<Alias, TableRef, JoinedTables>) => QueryBuilder<Alias, TableRef, JoinedTables>): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
39
|
+
where: GroupNode;
|
|
40
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
41
|
+
where: GroupNode;
|
|
42
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
43
|
+
where: GroupNode;
|
|
44
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
45
|
+
|
|
46
|
+
export { having, or, orGroup, where, whereGroup };
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var constants = require('../constants');
|
|
4
|
+
var core = require('./core');
|
|
5
|
+
|
|
6
|
+
function where(column, operator, value) {
|
|
7
|
+
return core.addCondition(
|
|
8
|
+
this,
|
|
9
|
+
constants.ConditionClause.WHERE,
|
|
10
|
+
column,
|
|
11
|
+
operator,
|
|
12
|
+
value || null,
|
|
13
|
+
constants.LogicalOperator.AND,
|
|
14
|
+
false
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function or(column, operator, value) {
|
|
18
|
+
return core.addCondition(
|
|
19
|
+
this,
|
|
20
|
+
constants.ConditionClause.WHERE,
|
|
21
|
+
column,
|
|
22
|
+
operator,
|
|
23
|
+
value || null,
|
|
24
|
+
constants.LogicalOperator.OR,
|
|
25
|
+
false
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
function having(column, operator, value) {
|
|
29
|
+
return core.addCondition(
|
|
30
|
+
this,
|
|
31
|
+
constants.ConditionClause.HAVING,
|
|
32
|
+
column,
|
|
33
|
+
operator,
|
|
34
|
+
value,
|
|
35
|
+
constants.LogicalOperator.AND,
|
|
36
|
+
false
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
function whereGroup(callback) {
|
|
40
|
+
return core.addGroupCondition(this, constants.LogicalOperator.AND, callback, false);
|
|
41
|
+
}
|
|
42
|
+
function orGroup(callback) {
|
|
43
|
+
return core.addGroupCondition(this, constants.LogicalOperator.OR, callback, false);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
exports.having = having;
|
|
47
|
+
exports.or = or;
|
|
48
|
+
exports.orGroup = orGroup;
|
|
49
|
+
exports.where = where;
|
|
50
|
+
exports.whereGroup = whereGroup;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { a as addCondition, b as addGroupCondition } from '../../index-K07efKgt.cjs';
|
|
2
|
+
import '../../column/index.cjs';
|
|
3
|
+
import '../constants.cjs';
|
|
4
|
+
import 'bun';
|
|
5
|
+
import '../../types.cjs';
|
|
6
|
+
import '../../column/constants.cjs';
|
|
7
|
+
import '../../table/constants.cjs';
|
|
8
|
+
import '../../column/types.cjs';
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __ = require('..');
|
|
4
|
+
var constants = require('../constants');
|
|
5
|
+
|
|
6
|
+
function addCondition(query, clause, column, operator, value, logical, negate) {
|
|
7
|
+
if (!query.table.dialect) {
|
|
8
|
+
throw new Error("No DB Dialect defined");
|
|
9
|
+
}
|
|
10
|
+
const validClause = clause.toLowerCase();
|
|
11
|
+
if (!query.definition[validClause]) {
|
|
12
|
+
query.definition[validClause] = {
|
|
13
|
+
type: constants.AstType.GROUP,
|
|
14
|
+
operator: constants.LogicalOperator.AND,
|
|
15
|
+
children: []
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
const root = query.definition[validClause];
|
|
19
|
+
let node = {
|
|
20
|
+
type: constants.AstType.COMPARISON,
|
|
21
|
+
column,
|
|
22
|
+
operator,
|
|
23
|
+
value,
|
|
24
|
+
values: value
|
|
25
|
+
};
|
|
26
|
+
if (node.type === constants.AstType.COMPARISON) {
|
|
27
|
+
if (node.operator === constants.AcceptedOperator.IS_NULL && "value" in node) {
|
|
28
|
+
delete node.value;
|
|
29
|
+
}
|
|
30
|
+
if (node.operator === constants.AcceptedOperator.STARTS_WITH) {
|
|
31
|
+
node.value = "%" + node.value;
|
|
32
|
+
}
|
|
33
|
+
if (node.operator === constants.AcceptedOperator.ENDS_WITH) {
|
|
34
|
+
node.value = node.value + "%";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
if (negate) {
|
|
38
|
+
node = {
|
|
39
|
+
type: constants.AstType.NOT,
|
|
40
|
+
child: node
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
if (operator === constants.AcceptedOperator.IS_NULL) {
|
|
44
|
+
return query;
|
|
45
|
+
}
|
|
46
|
+
if (root.operator === logical) {
|
|
47
|
+
root.children.push(node);
|
|
48
|
+
} else {
|
|
49
|
+
query.definition.where = {
|
|
50
|
+
type: constants.AstType.GROUP,
|
|
51
|
+
operator: logical,
|
|
52
|
+
children: [root, node]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return query;
|
|
56
|
+
}
|
|
57
|
+
function addGroupCondition(query, logical, callback, negate) {
|
|
58
|
+
const sub = callback(new __.QueryBuilder(query.table));
|
|
59
|
+
const subDef = sub.definition;
|
|
60
|
+
if (!query.definition.where) {
|
|
61
|
+
query.definition.where = {
|
|
62
|
+
type: constants.AstType.GROUP,
|
|
63
|
+
operator: constants.LogicalOperator.AND,
|
|
64
|
+
children: []
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
if (!subDef.where || subDef.where.children.length === 0) {
|
|
68
|
+
return query;
|
|
69
|
+
}
|
|
70
|
+
const root = query.definition.where;
|
|
71
|
+
let groupNode = subDef.where;
|
|
72
|
+
if (negate) {
|
|
73
|
+
groupNode = {
|
|
74
|
+
type: constants.AstType.NOT,
|
|
75
|
+
child: groupNode
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
if (root.operator === logical) {
|
|
79
|
+
root.children.push(groupNode);
|
|
80
|
+
} else {
|
|
81
|
+
query.definition.where = {
|
|
82
|
+
type: constants.AstType.GROUP,
|
|
83
|
+
operator: logical,
|
|
84
|
+
children: [root, groupNode]
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return query;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
exports.addCondition = addCondition;
|
|
91
|
+
exports.addGroupCondition = addGroupCondition;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export { having, or, orGroup, where, whereGroup } from './common.cjs';
|
|
2
|
+
export { a as addCondition, b as addGroupCondition } from '../../index-K07efKgt.cjs';
|
|
3
|
+
export { havingNot, orNot, orNotGroup, whereNot, whereNotGroup } from './not.cjs';
|
|
4
|
+
import '../../column/index.cjs';
|
|
5
|
+
import '../../table/constants.cjs';
|
|
6
|
+
import '../../column/constants.cjs';
|
|
7
|
+
import '../../column/types.cjs';
|
|
8
|
+
import '../constants.cjs';
|
|
9
|
+
import 'bun';
|
|
10
|
+
import '../../types.cjs';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var common = require('./common');
|
|
4
|
+
var core = require('./core');
|
|
5
|
+
var not = require('./not');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
Object.keys(common).forEach(function (k) {
|
|
10
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return common[k]; }
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
Object.keys(core).forEach(function (k) {
|
|
16
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
17
|
+
enumerable: true,
|
|
18
|
+
get: function () { return core[k]; }
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
Object.keys(not).forEach(function (k) {
|
|
22
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function () { return not[k]; }
|
|
25
|
+
});
|
|
26
|
+
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { T as Table, Q as QueryDefinition, C as ColumnSelector, S as StrictColumnSelector, W as WhereValue, c as QueryBuilder, e as QueryTransformerContract, f as QueryConditionContract, G as GroupNode } from '../../index-K07efKgt.cjs';
|
|
2
|
+
import { Column } from '../../column/index.cjs';
|
|
3
|
+
import { AcceptedOperator } from '../constants.cjs';
|
|
4
|
+
import 'bun';
|
|
5
|
+
import '../../types.cjs';
|
|
6
|
+
import '../../column/constants.cjs';
|
|
7
|
+
import '../../table/constants.cjs';
|
|
8
|
+
import '../../column/types.cjs';
|
|
9
|
+
|
|
10
|
+
declare function whereNot<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, ColName extends StrictAllowedColumn, Col extends ColName extends `${infer TableAlias}.${infer TableColumn}` ? TableAlias extends Alias ? TableRef['columns'][TableColumn] : JoinedTables[TableAlias]['columns'][TableColumn] : never, Operator extends AcceptedOperator, Value extends WhereValue<Col>[Operator]>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, column: ColName, operator: Operator, value?: Value): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
11
|
+
where: string[];
|
|
12
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
13
|
+
where: string[];
|
|
14
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
15
|
+
where: string[];
|
|
16
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
17
|
+
declare function havingNot<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, ColName extends StrictAllowedColumn, Col extends ColName extends `${infer TableAlias}.${infer TableColumn}` ? TableAlias extends Alias ? TableRef['columns'][TableColumn] : JoinedTables[TableAlias]['columns'][TableColumn] : never, Operator extends AcceptedOperator, Value extends WhereValue<Col>[Operator]>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, column: ColName, operator: Operator, value: Value): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "having"> & {
|
|
18
|
+
having: string[];
|
|
19
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "having"> & {
|
|
20
|
+
having: string[];
|
|
21
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "having"> & {
|
|
22
|
+
having: string[];
|
|
23
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
24
|
+
declare function orNot<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>, ColName extends StrictAllowedColumn, Col extends ColName extends `${infer TableAlias}.${infer TableColumn}` ? TableAlias extends Alias ? TableRef['columns'][TableColumn] : JoinedTables[TableAlias]['columns'][TableColumn] : never, Operator extends AcceptedOperator, Value extends WhereValue<Col>[Operator]>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, column: ColName, operator: Operator, value?: Value): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
25
|
+
where: string[];
|
|
26
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
27
|
+
where: string[];
|
|
28
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
29
|
+
where: string[];
|
|
30
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
31
|
+
declare function whereNotGroup<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, callback: (q: QueryBuilder<Alias, TableRef, JoinedTables>) => QueryBuilder<Alias, TableRef, JoinedTables>): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
32
|
+
where: GroupNode;
|
|
33
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
34
|
+
where: GroupNode;
|
|
35
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
36
|
+
where: GroupNode;
|
|
37
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
38
|
+
declare function orNotGroup<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>>(this: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, callback: (q: QueryBuilder<Alias, TableRef, JoinedTables>) => QueryBuilder<Alias, TableRef, JoinedTables>): QueryBuilder<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
39
|
+
where: GroupNode;
|
|
40
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>, QueryTransformerContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
41
|
+
where: GroupNode;
|
|
42
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>, QueryConditionContract<Alias, TableRef, JoinedTables, Omit<Definition, "where"> & {
|
|
43
|
+
where: GroupNode;
|
|
44
|
+
}, ColumnSelector<Alias, TableRef, JoinedTables>, StrictColumnSelector<Alias, TableRef, JoinedTables>>>;
|
|
45
|
+
|
|
46
|
+
export { havingNot, orNot, orNotGroup, whereNot, whereNotGroup };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
require('..');
|
|
4
|
+
var constants = require('../constants');
|
|
5
|
+
var core = require('./core');
|
|
6
|
+
|
|
7
|
+
function whereNot(column, operator, value) {
|
|
8
|
+
return core.addCondition(
|
|
9
|
+
this,
|
|
10
|
+
constants.ConditionClause.WHERE,
|
|
11
|
+
column,
|
|
12
|
+
operator,
|
|
13
|
+
value || null,
|
|
14
|
+
constants.LogicalOperator.AND,
|
|
15
|
+
true
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
function havingNot(column, operator, value) {
|
|
19
|
+
return core.addCondition(
|
|
20
|
+
this,
|
|
21
|
+
constants.ConditionClause.HAVING,
|
|
22
|
+
column,
|
|
23
|
+
operator,
|
|
24
|
+
value,
|
|
25
|
+
constants.LogicalOperator.AND,
|
|
26
|
+
true
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
function orNot(column, operator, value) {
|
|
30
|
+
return core.addCondition(
|
|
31
|
+
this,
|
|
32
|
+
constants.ConditionClause.WHERE,
|
|
33
|
+
column,
|
|
34
|
+
operator,
|
|
35
|
+
value || null,
|
|
36
|
+
constants.LogicalOperator.OR,
|
|
37
|
+
true
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
function whereNotGroup(callback) {
|
|
41
|
+
return core.addGroupCondition(this, constants.LogicalOperator.AND, callback, true);
|
|
42
|
+
}
|
|
43
|
+
function orNotGroup(callback) {
|
|
44
|
+
return core.addGroupCondition(this, constants.LogicalOperator.OR, callback, true);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.havingNot = havingNot;
|
|
48
|
+
exports.orNot = orNot;
|
|
49
|
+
exports.orNotGroup = orNotGroup;
|
|
50
|
+
exports.whereNot = whereNot;
|
|
51
|
+
exports.whereNotGroup = whereNotGroup;
|
|
@@ -3,6 +3,13 @@ declare const LogicalOperator: {
|
|
|
3
3
|
readonly OR: "OR";
|
|
4
4
|
};
|
|
5
5
|
type LogicalOperator = (typeof LogicalOperator)[keyof typeof LogicalOperator];
|
|
6
|
+
declare const AstType: {
|
|
7
|
+
readonly GROUP: "GROUP";
|
|
8
|
+
readonly COMPARISON: "COMPARISON";
|
|
9
|
+
readonly NOT: "NOT";
|
|
10
|
+
readonly JOIN: "JOIN";
|
|
11
|
+
};
|
|
12
|
+
type AstType = (typeof AstType)[keyof typeof AstType];
|
|
6
13
|
declare const ConditionClause: {
|
|
7
14
|
readonly WHERE: "WHERE";
|
|
8
15
|
readonly HAVING: "HAVING";
|
|
@@ -16,15 +23,14 @@ declare const AcceptedOperator: {
|
|
|
16
23
|
readonly GTE: "gte";
|
|
17
24
|
readonly LTE: "lte";
|
|
18
25
|
readonly IN: "in";
|
|
19
|
-
readonly NOT_IN: "notIn";
|
|
20
26
|
readonly LIKE: "like";
|
|
21
|
-
readonly NOT_LIKE: "notLike";
|
|
22
27
|
readonly ILIKE: "ilike";
|
|
23
|
-
readonly NOT_ILIKE: "notILike";
|
|
24
28
|
readonly IS_NULL: "isNull";
|
|
25
|
-
readonly IS_NOT_NULL: "isNotNull";
|
|
26
29
|
readonly BETWEEN: "between";
|
|
27
|
-
readonly
|
|
30
|
+
readonly STARTS_WITH: "startsWith";
|
|
31
|
+
readonly ENDS_WITH: "endsWith";
|
|
32
|
+
readonly REG_EXP: "regExp";
|
|
33
|
+
readonly RLIKE: "rlike";
|
|
28
34
|
};
|
|
29
35
|
type AcceptedOperator = (typeof AcceptedOperator)[keyof typeof AcceptedOperator];
|
|
30
36
|
declare const QueryType: {
|
|
@@ -51,6 +57,8 @@ declare const AcceptedJoin: {
|
|
|
51
57
|
readonly INNER: "INNER";
|
|
52
58
|
readonly LEFT: "LEFT";
|
|
53
59
|
readonly RIGHT: "RIGHT";
|
|
60
|
+
readonly FULL: "FULL OUTER";
|
|
61
|
+
readonly CROSS: "CROSS";
|
|
54
62
|
readonly NATURAL: "NATURAL";
|
|
55
63
|
};
|
|
56
64
|
type AcceptedJoin = (typeof AcceptedJoin)[keyof typeof AcceptedJoin];
|
|
@@ -59,5 +67,22 @@ declare const QueryHooksType: {
|
|
|
59
67
|
readonly BEFORE: "before";
|
|
60
68
|
};
|
|
61
69
|
type QueryHooksType = (typeof QueryHooksType)[keyof typeof QueryHooksType];
|
|
70
|
+
declare const ExplainFormat: {
|
|
71
|
+
readonly JSON: "JSON";
|
|
72
|
+
readonly TEXT: "TEXT";
|
|
73
|
+
readonly YAML: "YAML";
|
|
74
|
+
readonly XML: "XML";
|
|
75
|
+
};
|
|
76
|
+
type ExplainFormat = (typeof ExplainFormat)[keyof typeof ExplainFormat];
|
|
77
|
+
declare const ExplainClause: {
|
|
78
|
+
readonly FORMAT: "FORMAT";
|
|
79
|
+
readonly ANALYZE: "ANALYZE";
|
|
80
|
+
readonly VERBOSE: "VERBOSE";
|
|
81
|
+
readonly COSTS: "COSTS";
|
|
82
|
+
readonly BUFFERS: "BUFFERS";
|
|
83
|
+
readonly SUMMARY: "SUMMARY";
|
|
84
|
+
readonly TIMING: "TIMING";
|
|
85
|
+
};
|
|
86
|
+
type ExplainClause = (typeof ExplainClause)[keyof typeof ExplainClause];
|
|
62
87
|
|
|
63
|
-
export { AcceptedJoin, AcceptedOperator, AggregationFunction, ConditionClause, LogicalOperator, OrderBy, QueryHooksType, QueryType };
|
|
88
|
+
export { AcceptedJoin, AcceptedOperator, AggregationFunction, AstType, ConditionClause, ExplainClause, ExplainFormat, LogicalOperator, OrderBy, QueryHooksType, QueryType };
|
|
@@ -4,6 +4,12 @@ const LogicalOperator = {
|
|
|
4
4
|
AND: "AND",
|
|
5
5
|
OR: "OR"
|
|
6
6
|
};
|
|
7
|
+
const AstType = {
|
|
8
|
+
GROUP: "GROUP",
|
|
9
|
+
COMPARISON: "COMPARISON",
|
|
10
|
+
NOT: "NOT",
|
|
11
|
+
JOIN: "JOIN"
|
|
12
|
+
};
|
|
7
13
|
const ConditionClause = {
|
|
8
14
|
WHERE: "WHERE",
|
|
9
15
|
HAVING: "HAVING"
|
|
@@ -16,15 +22,14 @@ const AcceptedOperator = {
|
|
|
16
22
|
GTE: "gte",
|
|
17
23
|
LTE: "lte",
|
|
18
24
|
IN: "in",
|
|
19
|
-
NOT_IN: "notIn",
|
|
20
25
|
LIKE: "like",
|
|
21
|
-
NOT_LIKE: "notLike",
|
|
22
26
|
ILIKE: "ilike",
|
|
23
|
-
NOT_ILIKE: "notILike",
|
|
24
27
|
IS_NULL: "isNull",
|
|
25
|
-
IS_NOT_NULL: "isNotNull",
|
|
26
28
|
BETWEEN: "between",
|
|
27
|
-
|
|
29
|
+
STARTS_WITH: "startsWith",
|
|
30
|
+
ENDS_WITH: "endsWith",
|
|
31
|
+
REG_EXP: "regExp",
|
|
32
|
+
RLIKE: "rlike"
|
|
28
33
|
};
|
|
29
34
|
const QueryType = {
|
|
30
35
|
SELECT: "SELECT",
|
|
@@ -47,17 +52,37 @@ const AcceptedJoin = {
|
|
|
47
52
|
INNER: "INNER",
|
|
48
53
|
LEFT: "LEFT",
|
|
49
54
|
RIGHT: "RIGHT",
|
|
55
|
+
FULL: "FULL OUTER",
|
|
56
|
+
CROSS: "CROSS",
|
|
50
57
|
NATURAL: "NATURAL"
|
|
51
58
|
};
|
|
52
59
|
const QueryHooksType = {
|
|
53
60
|
AFTER: "after",
|
|
54
61
|
BEFORE: "before"
|
|
55
62
|
};
|
|
63
|
+
const ExplainFormat = {
|
|
64
|
+
JSON: "JSON",
|
|
65
|
+
TEXT: "TEXT",
|
|
66
|
+
YAML: "YAML",
|
|
67
|
+
XML: "XML"
|
|
68
|
+
};
|
|
69
|
+
const ExplainClause = {
|
|
70
|
+
FORMAT: "FORMAT",
|
|
71
|
+
ANALYZE: "ANALYZE",
|
|
72
|
+
VERBOSE: "VERBOSE",
|
|
73
|
+
COSTS: "COSTS",
|
|
74
|
+
BUFFERS: "BUFFERS",
|
|
75
|
+
SUMMARY: "SUMMARY",
|
|
76
|
+
TIMING: "TIMING"
|
|
77
|
+
};
|
|
56
78
|
|
|
57
79
|
exports.AcceptedJoin = AcceptedJoin;
|
|
58
80
|
exports.AcceptedOperator = AcceptedOperator;
|
|
59
81
|
exports.AggregationFunction = AggregationFunction;
|
|
82
|
+
exports.AstType = AstType;
|
|
60
83
|
exports.ConditionClause = ConditionClause;
|
|
84
|
+
exports.ExplainClause = ExplainClause;
|
|
85
|
+
exports.ExplainFormat = ExplainFormat;
|
|
61
86
|
exports.LogicalOperator = LogicalOperator;
|
|
62
87
|
exports.OrderBy = OrderBy;
|
|
63
88
|
exports.QueryHooksType = QueryHooksType;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import 'bun';
|
|
2
|
-
export {
|
|
2
|
+
export { f as QueryConditionContract, e as QueryTransformerContract } from '../index-K07efKgt.cjs';
|
|
3
3
|
import '../column/index.cjs';
|
|
4
4
|
import '../table/constants.cjs';
|
|
5
5
|
import './constants.cjs';
|
|
6
|
-
import '../column/constants.cjs';
|
|
7
6
|
import '../types.cjs';
|
|
7
|
+
import '../column/constants.cjs';
|
|
8
8
|
import '../column/types.cjs';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { T as Table, Q as QueryDefinition, C as ColumnSelector, S as StrictColumnSelector, c as QueryBuilder, E as ExplainOptions } from '../index-K07efKgt.cjs';
|
|
2
|
+
import { Column } from '../column/index.cjs';
|
|
3
|
+
import 'bun';
|
|
4
|
+
import '../types.cjs';
|
|
5
|
+
import './constants.cjs';
|
|
6
|
+
import '../column/constants.cjs';
|
|
7
|
+
import '../table/constants.cjs';
|
|
8
|
+
import '../column/types.cjs';
|
|
9
|
+
|
|
10
|
+
declare function buildExplainQuery<Alias extends string, TableRef extends Table<string, Record<string, Column>>, JoinedTables extends Record<string, Table<string, Record<string, Column>>>, Definition extends Partial<QueryDefinition<Alias, TableRef, JoinedTables>>, AllowedColumn extends ColumnSelector<Alias, TableRef, JoinedTables>, StrictAllowedColumn extends StrictColumnSelector<Alias, TableRef, JoinedTables>>(q: QueryBuilder<Alias, TableRef, JoinedTables, Definition, AllowedColumn, StrictAllowedColumn>, options: Partial<ExplainOptions>): string;
|
|
11
|
+
|
|
12
|
+
export { buildExplainQuery };
|