@ignisia/sql 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/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-CnQVnCEI.d.cts → index-CHxuUiO4.d.cts} +178 -98
- package/dist/cjs/{index-2jl8MRfX.d.cts → index-CZhrzE5r.d.cts} +2 -2
- 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/builder.d.cts +3 -3
- package/dist/cjs/query/builder.js +1 -1
- package/dist/cjs/query/condition/common.d.cts +41 -0
- package/dist/cjs/query/condition/common.js +62 -0
- package/dist/cjs/query/condition/core.d.cts +8 -0
- package/dist/cjs/query/condition/core.js +57 -0
- package/dist/cjs/query/condition/index.d.cts +10 -0
- package/dist/cjs/query/condition/index.js +33 -0
- package/dist/cjs/query/condition/not.d.cts +34 -0
- package/dist/cjs/query/condition/not.js +51 -0
- package/dist/cjs/query/condition/raw.d.cts +8 -0
- package/dist/cjs/query/condition/raw.js +54 -0
- package/dist/cjs/query/constants.d.cts +27 -1
- package/dist/cjs/query/constants.js +28 -2
- 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 -1
- package/dist/cjs/query/index.d.cts +2 -2
- package/dist/cjs/query/index.js +59 -64
- package/dist/cjs/query/join.d.cts +18 -6
- package/dist/cjs/query/join.js +38 -9
- package/dist/cjs/query/sql.d.cts +5 -3
- package/dist/cjs/query/sql.js +46 -15
- package/dist/cjs/query/types.d.cts +2 -2
- package/dist/cjs/query/utilities.d.cts +5 -4
- package/dist/cjs/query/utilities.js +73 -2
- 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-BdpoD4zk.d.ts → index-CjurLJdK.d.ts} +178 -98
- package/dist/esm/{index-BXOAxB_h.d.ts → index-DgOs61lH.d.ts} +2 -2
- 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/builder.d.ts +3 -3
- package/dist/esm/query/builder.js +1 -1
- package/dist/esm/query/condition/common.d.ts +41 -0
- package/dist/esm/query/condition/common.js +56 -0
- package/dist/esm/query/condition/core.d.ts +8 -0
- package/dist/esm/query/condition/core.js +55 -0
- package/dist/esm/query/condition/index.d.ts +10 -0
- package/dist/esm/query/condition/index.js +4 -0
- package/dist/esm/query/condition/not.d.ts +34 -0
- package/dist/esm/query/condition/not.js +46 -0
- package/dist/esm/query/condition/raw.d.ts +8 -0
- package/dist/esm/query/condition/raw.js +50 -0
- package/dist/esm/query/constants.d.ts +27 -1
- package/dist/esm/query/constants.js +27 -3
- 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 +2 -2
- package/dist/esm/query/index.d.ts +2 -2
- package/dist/esm/query/index.js +62 -67
- package/dist/esm/query/join.d.ts +18 -6
- package/dist/esm/query/join.js +37 -9
- package/dist/esm/query/sql.d.ts +5 -3
- package/dist/esm/query/sql.js +46 -17
- package/dist/esm/query/types.d.ts +2 -2
- package/dist/esm/query/utilities.d.ts +5 -4
- package/dist/esm/query/utilities.js +73 -3
- 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 +8 -2
- 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
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"main": "dist/cjs/index.js",
|
|
4
4
|
"module": "dist/esm/index.js",
|
|
5
5
|
"types": "./dist/esm/index.d.ts",
|
|
6
|
-
"version": "0.
|
|
6
|
+
"version": "0.4.0",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
@@ -42,6 +42,11 @@
|
|
|
42
42
|
"import": "./dist/esm/query/index.js",
|
|
43
43
|
"require": "./dist/cjs/query/index.js"
|
|
44
44
|
},
|
|
45
|
+
"./query/condition": {
|
|
46
|
+
"types": "./dist/esm/query/condition/index.d.ts",
|
|
47
|
+
"import": "./dist/esm/query/condition/index.js",
|
|
48
|
+
"require": "./dist/cjs/query/condition/index.js"
|
|
49
|
+
},
|
|
45
50
|
"./table": {
|
|
46
51
|
"types": "./dist/esm/table/index.d.ts",
|
|
47
52
|
"import": "./dist/esm/table/index.js",
|
|
@@ -73,6 +78,7 @@
|
|
|
73
78
|
"sql",
|
|
74
79
|
"database",
|
|
75
80
|
"sqlite",
|
|
76
|
-
"postgres"
|
|
81
|
+
"postgres",
|
|
82
|
+
"mysql"
|
|
77
83
|
]
|
|
78
84
|
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { N as addCondition, I as addRawCondition, V as having, U as or, L as rawHaving, K as rawOr, J as rawWhere, O as where } from '../index-CnQVnCEI.cjs';
|
|
2
|
-
import '../column/index.cjs';
|
|
3
|
-
import './constants.cjs';
|
|
4
|
-
import '../column/constants.cjs';
|
|
5
|
-
import '../types.cjs';
|
|
6
|
-
import 'bun';
|
|
7
|
-
import '../table/constants.cjs';
|
|
8
|
-
import '../column/types.cjs';
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var constants = require('./constants');
|
|
4
|
-
var helper = require('./helper');
|
|
5
|
-
var utilities = require('./utilities');
|
|
6
|
-
|
|
7
|
-
function addRawCondition(query, clause, column, logical, params) {
|
|
8
|
-
const validClause = clause.toLowerCase();
|
|
9
|
-
if (!query.definition[validClause]) query.definition[validClause] = [];
|
|
10
|
-
const condition = column(helper.rawCol);
|
|
11
|
-
const logicalPrefix = query.definition[validClause].length > 0 ? logical : "";
|
|
12
|
-
query.definition[validClause].push(`${logicalPrefix} ${condition}`.trim());
|
|
13
|
-
if (!query.definition.params) query.definition.params = [];
|
|
14
|
-
if (typeof params === "undefined") {
|
|
15
|
-
return query;
|
|
16
|
-
}
|
|
17
|
-
if (Array.isArray(params)) {
|
|
18
|
-
query.definition.params.push(...params);
|
|
19
|
-
} else {
|
|
20
|
-
query.definition.params.push(params);
|
|
21
|
-
}
|
|
22
|
-
return query;
|
|
23
|
-
}
|
|
24
|
-
function rawWhere(column, params) {
|
|
25
|
-
return addRawCondition(
|
|
26
|
-
this,
|
|
27
|
-
constants.ConditionClause.WHERE,
|
|
28
|
-
column,
|
|
29
|
-
constants.LogicalOperator.AND,
|
|
30
|
-
params
|
|
31
|
-
);
|
|
32
|
-
}
|
|
33
|
-
function rawOr(column, params) {
|
|
34
|
-
return addRawCondition(
|
|
35
|
-
this,
|
|
36
|
-
constants.ConditionClause.WHERE,
|
|
37
|
-
column,
|
|
38
|
-
constants.LogicalOperator.OR,
|
|
39
|
-
params
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
function rawHaving(column, params) {
|
|
43
|
-
return addRawCondition(
|
|
44
|
-
this,
|
|
45
|
-
constants.ConditionClause.HAVING,
|
|
46
|
-
column,
|
|
47
|
-
constants.LogicalOperator.AND,
|
|
48
|
-
params
|
|
49
|
-
);
|
|
50
|
-
}
|
|
51
|
-
function addCondition(query, clause, column, operator, value, logical) {
|
|
52
|
-
if (!query.table.dialect) {
|
|
53
|
-
throw new Error("No DB Dialect defined");
|
|
54
|
-
}
|
|
55
|
-
const validClause = clause.toLowerCase();
|
|
56
|
-
const condition = utilities.getCondition(query.table.dialect, column, operator, value);
|
|
57
|
-
if (!query.definition[validClause]) query.definition[validClause] = [];
|
|
58
|
-
const logicalPrefix = query.definition[validClause].length > 0 ? logical : "";
|
|
59
|
-
query.definition[validClause].push(`${logicalPrefix} ${condition}`.trim());
|
|
60
|
-
if (operator === constants.AcceptedOperator.IS_NULL || operator === constants.AcceptedOperator.IS_NOT_NULL) {
|
|
61
|
-
return query;
|
|
62
|
-
}
|
|
63
|
-
if (!query.definition.params) query.definition.params = [];
|
|
64
|
-
if (Array.isArray(value)) {
|
|
65
|
-
query.definition.params.push(...value);
|
|
66
|
-
} else {
|
|
67
|
-
query.definition.params.push(value);
|
|
68
|
-
}
|
|
69
|
-
return query;
|
|
70
|
-
}
|
|
71
|
-
function where(column, operator, value) {
|
|
72
|
-
return addCondition(
|
|
73
|
-
this,
|
|
74
|
-
constants.ConditionClause.WHERE,
|
|
75
|
-
column,
|
|
76
|
-
operator,
|
|
77
|
-
value || null,
|
|
78
|
-
constants.LogicalOperator.AND
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
function or(column, operator, value) {
|
|
82
|
-
return addCondition(
|
|
83
|
-
this,
|
|
84
|
-
constants.ConditionClause.WHERE,
|
|
85
|
-
column,
|
|
86
|
-
operator,
|
|
87
|
-
value || null,
|
|
88
|
-
constants.LogicalOperator.OR
|
|
89
|
-
);
|
|
90
|
-
}
|
|
91
|
-
function having(column, operator, value) {
|
|
92
|
-
return addCondition(
|
|
93
|
-
this,
|
|
94
|
-
constants.ConditionClause.HAVING,
|
|
95
|
-
column,
|
|
96
|
-
operator,
|
|
97
|
-
value,
|
|
98
|
-
constants.LogicalOperator.AND
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
exports.addCondition = addCondition;
|
|
103
|
-
exports.addRawCondition = addRawCondition;
|
|
104
|
-
exports.having = having;
|
|
105
|
-
exports.or = or;
|
|
106
|
-
exports.rawHaving = rawHaving;
|
|
107
|
-
exports.rawOr = rawOr;
|
|
108
|
-
exports.rawWhere = rawWhere;
|
|
109
|
-
exports.where = where;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export { N as addCondition, I as addRawCondition, V as having, U as or, L as rawHaving, K as rawOr, J as rawWhere, O as where } from '../index-BdpoD4zk.js';
|
|
2
|
-
import '../column/index.js';
|
|
3
|
-
import './constants.js';
|
|
4
|
-
import '../column/constants.js';
|
|
5
|
-
import '../types.js';
|
|
6
|
-
import 'bun';
|
|
7
|
-
import '../table/constants.js';
|
|
8
|
-
import '../column/types.js';
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { LogicalOperator, ConditionClause, AcceptedOperator } from './constants.js';
|
|
2
|
-
import { rawCol } from './helper.js';
|
|
3
|
-
import { getCondition } from './utilities.js';
|
|
4
|
-
|
|
5
|
-
// src/query/condition.ts
|
|
6
|
-
function addRawCondition(query, clause, column, logical, params) {
|
|
7
|
-
const validClause = clause.toLowerCase();
|
|
8
|
-
if (!query.definition[validClause]) query.definition[validClause] = [];
|
|
9
|
-
const condition = column(rawCol);
|
|
10
|
-
const logicalPrefix = query.definition[validClause].length > 0 ? logical : "";
|
|
11
|
-
query.definition[validClause].push(`${logicalPrefix} ${condition}`.trim());
|
|
12
|
-
if (!query.definition.params) query.definition.params = [];
|
|
13
|
-
if (typeof params === "undefined") {
|
|
14
|
-
return query;
|
|
15
|
-
}
|
|
16
|
-
if (Array.isArray(params)) {
|
|
17
|
-
query.definition.params.push(...params);
|
|
18
|
-
} else {
|
|
19
|
-
query.definition.params.push(params);
|
|
20
|
-
}
|
|
21
|
-
return query;
|
|
22
|
-
}
|
|
23
|
-
function rawWhere(column, params) {
|
|
24
|
-
return addRawCondition(
|
|
25
|
-
this,
|
|
26
|
-
ConditionClause.WHERE,
|
|
27
|
-
column,
|
|
28
|
-
LogicalOperator.AND,
|
|
29
|
-
params
|
|
30
|
-
);
|
|
31
|
-
}
|
|
32
|
-
function rawOr(column, params) {
|
|
33
|
-
return addRawCondition(
|
|
34
|
-
this,
|
|
35
|
-
ConditionClause.WHERE,
|
|
36
|
-
column,
|
|
37
|
-
LogicalOperator.OR,
|
|
38
|
-
params
|
|
39
|
-
);
|
|
40
|
-
}
|
|
41
|
-
function rawHaving(column, params) {
|
|
42
|
-
return addRawCondition(
|
|
43
|
-
this,
|
|
44
|
-
ConditionClause.HAVING,
|
|
45
|
-
column,
|
|
46
|
-
LogicalOperator.AND,
|
|
47
|
-
params
|
|
48
|
-
);
|
|
49
|
-
}
|
|
50
|
-
function addCondition(query, clause, column, operator, value, logical) {
|
|
51
|
-
if (!query.table.dialect) {
|
|
52
|
-
throw new Error("No DB Dialect defined");
|
|
53
|
-
}
|
|
54
|
-
const validClause = clause.toLowerCase();
|
|
55
|
-
const condition = getCondition(query.table.dialect, column, operator, value);
|
|
56
|
-
if (!query.definition[validClause]) query.definition[validClause] = [];
|
|
57
|
-
const logicalPrefix = query.definition[validClause].length > 0 ? logical : "";
|
|
58
|
-
query.definition[validClause].push(`${logicalPrefix} ${condition}`.trim());
|
|
59
|
-
if (operator === AcceptedOperator.IS_NULL || operator === AcceptedOperator.IS_NOT_NULL) {
|
|
60
|
-
return query;
|
|
61
|
-
}
|
|
62
|
-
if (!query.definition.params) query.definition.params = [];
|
|
63
|
-
if (Array.isArray(value)) {
|
|
64
|
-
query.definition.params.push(...value);
|
|
65
|
-
} else {
|
|
66
|
-
query.definition.params.push(value);
|
|
67
|
-
}
|
|
68
|
-
return query;
|
|
69
|
-
}
|
|
70
|
-
function where(column, operator, value) {
|
|
71
|
-
return addCondition(
|
|
72
|
-
this,
|
|
73
|
-
ConditionClause.WHERE,
|
|
74
|
-
column,
|
|
75
|
-
operator,
|
|
76
|
-
value || null,
|
|
77
|
-
LogicalOperator.AND
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
function or(column, operator, value) {
|
|
81
|
-
return addCondition(
|
|
82
|
-
this,
|
|
83
|
-
ConditionClause.WHERE,
|
|
84
|
-
column,
|
|
85
|
-
operator,
|
|
86
|
-
value || null,
|
|
87
|
-
LogicalOperator.OR
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
function having(column, operator, value) {
|
|
91
|
-
return addCondition(
|
|
92
|
-
this,
|
|
93
|
-
ConditionClause.HAVING,
|
|
94
|
-
column,
|
|
95
|
-
operator,
|
|
96
|
-
value,
|
|
97
|
-
LogicalOperator.AND
|
|
98
|
-
);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export { addCondition, addRawCondition, having, or, rawHaving, rawOr, rawWhere, where };
|