@stamhoofd/sql 2.119.0 → 2.120.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/dist/{src/ModelCache.d.ts → ModelCache.d.ts} +1 -1
- package/dist/ModelCache.d.ts.map +1 -0
- package/{src/ModelCache.ts → dist/ModelCache.js} +8 -16
- package/dist/ModelCache.js.map +1 -0
- package/dist/{src/QueryableModel.d.ts → QueryableModel.d.ts} +7 -6
- package/dist/QueryableModel.d.ts.map +1 -0
- package/dist/{src/QueryableModel.js → QueryableModel.js} +9 -13
- package/dist/QueryableModel.js.map +1 -0
- package/dist/{src/SQL.d.ts → SQL.d.ts} +7 -5
- package/dist/SQL.d.ts.map +1 -0
- package/dist/SQL.js +100 -0
- package/dist/SQL.js.map +1 -0
- package/dist/{src/SQLDelete.d.ts → SQLDelete.d.ts} +2 -2
- package/dist/SQLDelete.d.ts.map +1 -0
- package/dist/{src/SQLDelete.js → SQLDelete.js} +8 -12
- package/dist/SQLDelete.js.map +1 -0
- package/dist/SQLExpression.d.ts.map +1 -0
- package/dist/{src/SQLExpression.js → SQLExpression.js} +3 -8
- package/dist/SQLExpression.js.map +1 -0
- package/dist/{src/SQLExpressions.d.ts → SQLExpressions.d.ts} +2 -2
- package/dist/SQLExpressions.d.ts.map +1 -0
- package/dist/{src/SQLExpressions.js → SQLExpressions.js} +78 -115
- package/dist/SQLExpressions.js.map +1 -0
- package/dist/{src/SQLInsert.d.ts → SQLInsert.d.ts} +3 -2
- package/dist/SQLInsert.d.ts.map +1 -0
- package/dist/{src/SQLInsert.js → SQLInsert.js} +17 -21
- package/dist/SQLInsert.js.map +1 -0
- package/dist/{src/SQLJoin.d.ts → SQLJoin.d.ts} +1 -1
- package/dist/SQLJoin.d.ts.map +1 -0
- package/{src/SQLJoin.ts → dist/SQLJoin.js} +15 -18
- package/dist/SQLJoin.js.map +1 -0
- package/dist/{src/SQLJsonExpressions.d.ts → SQLJsonExpressions.d.ts} +2 -2
- package/dist/SQLJsonExpressions.d.ts.map +1 -0
- package/dist/{src/SQLJsonExpressions.js → SQLJsonExpressions.js} +31 -44
- package/dist/SQLJsonExpressions.js.map +1 -0
- package/dist/SQLLogger.d.ts.map +1 -0
- package/dist/{src/SQLLogger.js → SQLLogger.js} +5 -8
- package/dist/SQLLogger.js.map +1 -0
- package/dist/{src/SQLOrderBy.d.ts → SQLOrderBy.d.ts} +1 -1
- package/dist/SQLOrderBy.d.ts.map +1 -0
- package/dist/{src/SQLOrderBy.js → SQLOrderBy.js} +8 -13
- package/dist/SQLOrderBy.js.map +1 -0
- package/dist/{src/SQLSelect.d.ts → SQLSelect.d.ts} +3 -3
- package/dist/SQLSelect.d.ts.map +1 -0
- package/dist/{src/SQLSelect.js → SQLSelect.js} +24 -29
- package/dist/SQLSelect.js.map +1 -0
- package/dist/{src/SQLTranslatedStringHelper.d.ts → SQLTranslatedStringHelper.d.ts} +3 -2
- package/dist/SQLTranslatedStringHelper.d.ts.map +1 -0
- package/dist/SQLTranslatedStringHelper.js +33 -0
- package/dist/SQLTranslatedStringHelper.js.map +1 -0
- package/dist/{src/SQLUpdate.d.ts → SQLUpdate.d.ts} +3 -2
- package/dist/SQLUpdate.d.ts.map +1 -0
- package/{src/SQLUpdate.ts → dist/SQLUpdate.js} +18 -35
- package/dist/SQLUpdate.js.map +1 -0
- package/dist/{src/SQLWhere.d.ts → SQLWhere.d.ts} +3 -3
- package/dist/SQLWhere.d.ts.map +1 -0
- package/dist/{src/SQLWhere.js → SQLWhere.js} +42 -56
- package/dist/SQLWhere.js.map +1 -0
- package/dist/{src/filters → filters}/SQLFilter.d.ts +5 -5
- package/dist/filters/SQLFilter.d.ts.map +1 -0
- package/{src/filters/SQLFilter.ts → dist/filters/SQLFilter.js} +55 -121
- package/dist/filters/SQLFilter.js.map +1 -0
- package/dist/{src/filters → filters}/SQLSorter.d.ts +6 -6
- package/dist/filters/SQLSorter.d.ts.map +1 -0
- package/dist/{src/filters → filters}/SQLSorter.js +4 -7
- package/dist/filters/SQLSorter.js.map +1 -0
- package/dist/filters/compilers/contains.d.ts +4 -0
- package/dist/filters/compilers/contains.d.ts.map +1 -0
- package/{src/filters/compilers/contains.ts → dist/filters/compilers/contains.js} +7 -25
- package/dist/filters/compilers/contains.js.map +1 -0
- package/dist/filters/compilers/equals.d.ts +4 -0
- package/dist/filters/compilers/equals.d.ts.map +1 -0
- package/dist/filters/compilers/equals.js +44 -0
- package/dist/filters/compilers/equals.js.map +1 -0
- package/dist/filters/compilers/greater.d.ts +4 -0
- package/dist/filters/compilers/greater.d.ts.map +1 -0
- package/dist/filters/compilers/greater.js +15 -0
- package/dist/filters/compilers/greater.js.map +1 -0
- package/dist/filters/compilers/in.d.ts +4 -0
- package/dist/filters/compilers/in.d.ts.map +1 -0
- package/{src/filters/compilers/in.ts → dist/filters/compilers/in.js} +7 -21
- package/dist/filters/compilers/in.js.map +1 -0
- package/dist/filters/compilers/index.d.ts.map +1 -0
- package/{src/filters/compilers/index.ts → dist/filters/compilers/index.js} +1 -0
- package/dist/filters/compilers/index.js.map +1 -0
- package/dist/filters/compilers/less.d.ts +4 -0
- package/dist/filters/compilers/less.d.ts.map +1 -0
- package/dist/filters/compilers/less.js +15 -0
- package/dist/filters/compilers/less.js.map +1 -0
- package/dist/filters/helpers/isJSONColumn.d.ts +5 -0
- package/dist/filters/helpers/isJSONColumn.d.ts.map +1 -0
- package/{src/filters/helpers/isJSONColumn.ts → dist/filters/helpers/isJSONColumn.js} +4 -5
- package/dist/filters/helpers/isJSONColumn.js.map +1 -0
- package/dist/{src/filters → filters}/helpers/normalizeCompareValue.d.ts +1 -1
- package/dist/filters/helpers/normalizeCompareValue.d.ts.map +1 -0
- package/{src/filters/helpers/normalizeCompareValue.ts → dist/filters/helpers/normalizeCompareValue.js} +2 -20
- package/dist/filters/helpers/normalizeCompareValue.js.map +1 -0
- package/dist/index.d.ts +14 -14
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -25
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/dist/src/ModelCache.d.ts.map +0 -1
- package/dist/src/ModelCache.js +0 -57
- package/dist/src/ModelCache.js.map +0 -1
- package/dist/src/QueryableModel.d.ts.map +0 -1
- package/dist/src/QueryableModel.js.map +0 -1
- package/dist/src/SQL.d.ts.map +0 -1
- package/dist/src/SQL.js +0 -103
- package/dist/src/SQL.js.map +0 -1
- package/dist/src/SQLDelete.d.ts.map +0 -1
- package/dist/src/SQLDelete.js.map +0 -1
- package/dist/src/SQLExpression.d.ts.map +0 -1
- package/dist/src/SQLExpression.js.map +0 -1
- package/dist/src/SQLExpressions.d.ts.map +0 -1
- package/dist/src/SQLExpressions.js.map +0 -1
- package/dist/src/SQLInsert.d.ts.map +0 -1
- package/dist/src/SQLInsert.js.map +0 -1
- package/dist/src/SQLJoin.d.ts.map +0 -1
- package/dist/src/SQLJoin.js +0 -61
- package/dist/src/SQLJoin.js.map +0 -1
- package/dist/src/SQLJsonExpressions.d.ts.map +0 -1
- package/dist/src/SQLJsonExpressions.js.map +0 -1
- package/dist/src/SQLLogger.d.ts.map +0 -1
- package/dist/src/SQLLogger.js.map +0 -1
- package/dist/src/SQLOrderBy.d.ts.map +0 -1
- package/dist/src/SQLOrderBy.js.map +0 -1
- package/dist/src/SQLSelect.d.ts.map +0 -1
- package/dist/src/SQLSelect.js.map +0 -1
- package/dist/src/SQLTranslatedStringHelper.d.ts.map +0 -1
- package/dist/src/SQLTranslatedStringHelper.js +0 -37
- package/dist/src/SQLTranslatedStringHelper.js.map +0 -1
- package/dist/src/SQLUpdate.d.ts.map +0 -1
- package/dist/src/SQLUpdate.js +0 -60
- package/dist/src/SQLUpdate.js.map +0 -1
- package/dist/src/SQLWhere.d.ts.map +0 -1
- package/dist/src/SQLWhere.js.map +0 -1
- package/dist/src/filters/SQLFilter.d.ts.map +0 -1
- package/dist/src/filters/SQLFilter.js +0 -220
- package/dist/src/filters/SQLFilter.js.map +0 -1
- package/dist/src/filters/SQLSorter.d.ts.map +0 -1
- package/dist/src/filters/SQLSorter.js.map +0 -1
- package/dist/src/filters/compilers/contains.d.ts +0 -4
- package/dist/src/filters/compilers/contains.d.ts.map +0 -1
- package/dist/src/filters/compilers/contains.js +0 -29
- package/dist/src/filters/compilers/contains.js.map +0 -1
- package/dist/src/filters/compilers/equals.d.ts +0 -4
- package/dist/src/filters/compilers/equals.d.ts.map +0 -1
- package/dist/src/filters/compilers/equals.js +0 -47
- package/dist/src/filters/compilers/equals.js.map +0 -1
- package/dist/src/filters/compilers/greater.d.ts +0 -4
- package/dist/src/filters/compilers/greater.d.ts.map +0 -1
- package/dist/src/filters/compilers/greater.js +0 -18
- package/dist/src/filters/compilers/greater.js.map +0 -1
- package/dist/src/filters/compilers/in.d.ts +0 -4
- package/dist/src/filters/compilers/in.d.ts.map +0 -1
- package/dist/src/filters/compilers/in.js +0 -51
- package/dist/src/filters/compilers/in.js.map +0 -1
- package/dist/src/filters/compilers/index.d.ts.map +0 -1
- package/dist/src/filters/compilers/index.js +0 -8
- package/dist/src/filters/compilers/index.js.map +0 -1
- package/dist/src/filters/compilers/less.d.ts +0 -4
- package/dist/src/filters/compilers/less.d.ts.map +0 -1
- package/dist/src/filters/compilers/less.js +0 -18
- package/dist/src/filters/compilers/less.js.map +0 -1
- package/dist/src/filters/helpers/isJSONColumn.d.ts +0 -4
- package/dist/src/filters/helpers/isJSONColumn.d.ts.map +0 -1
- package/dist/src/filters/helpers/isJSONColumn.js +0 -17
- package/dist/src/filters/helpers/isJSONColumn.js.map +0 -1
- package/dist/src/filters/helpers/normalizeCompareValue.d.ts.map +0 -1
- package/dist/src/filters/helpers/normalizeCompareValue.js +0 -87
- package/dist/src/filters/helpers/normalizeCompareValue.js.map +0 -1
- package/dist/tests/filters/$and.test.d.ts +0 -2
- package/dist/tests/filters/$and.test.d.ts.map +0 -1
- package/dist/tests/filters/$and.test.js +0 -216
- package/dist/tests/filters/$and.test.js.map +0 -1
- package/dist/tests/filters/$contains.test.d.ts +0 -2
- package/dist/tests/filters/$contains.test.d.ts.map +0 -1
- package/dist/tests/filters/$contains.test.js +0 -917
- package/dist/tests/filters/$contains.test.js.map +0 -1
- package/dist/tests/filters/$eq.test.d.ts +0 -2
- package/dist/tests/filters/$eq.test.d.ts.map +0 -1
- package/dist/tests/filters/$eq.test.js +0 -1464
- package/dist/tests/filters/$eq.test.js.map +0 -1
- package/dist/tests/filters/$gt.test.d.ts +0 -2
- package/dist/tests/filters/$gt.test.d.ts.map +0 -1
- package/dist/tests/filters/$gt.test.js +0 -641
- package/dist/tests/filters/$gt.test.js.map +0 -1
- package/dist/tests/filters/$gte.test.d.ts +0 -2
- package/dist/tests/filters/$gte.test.d.ts.map +0 -1
- package/dist/tests/filters/$gte.test.js +0 -433
- package/dist/tests/filters/$gte.test.js.map +0 -1
- package/dist/tests/filters/$in.test.d.ts +0 -2
- package/dist/tests/filters/$in.test.d.ts.map +0 -1
- package/dist/tests/filters/$in.test.js +0 -773
- package/dist/tests/filters/$in.test.js.map +0 -1
- package/dist/tests/filters/$lt.test.d.ts +0 -2
- package/dist/tests/filters/$lt.test.d.ts.map +0 -1
- package/dist/tests/filters/$lt.test.js +0 -433
- package/dist/tests/filters/$lt.test.js.map +0 -1
- package/dist/tests/filters/$lte.test.d.ts +0 -2
- package/dist/tests/filters/$lte.test.d.ts.map +0 -1
- package/dist/tests/filters/$lte.test.js +0 -472
- package/dist/tests/filters/$lte.test.js.map +0 -1
- package/dist/tests/filters/$neq.test.d.ts +0 -2
- package/dist/tests/filters/$neq.test.d.ts.map +0 -1
- package/dist/tests/filters/$neq.test.js +0 -32
- package/dist/tests/filters/$neq.test.js.map +0 -1
- package/dist/tests/filters/$not.test.d.ts +0 -2
- package/dist/tests/filters/$not.test.d.ts.map +0 -1
- package/dist/tests/filters/$not.test.js +0 -50
- package/dist/tests/filters/$not.test.js.map +0 -1
- package/dist/tests/filters/$or.test.d.ts +0 -2
- package/dist/tests/filters/$or.test.d.ts.map +0 -1
- package/dist/tests/filters/$or.test.js +0 -185
- package/dist/tests/filters/$or.test.js.map +0 -1
- package/dist/tests/filters/SQLTranslatedStringHelper.test.d.ts +0 -2
- package/dist/tests/filters/SQLTranslatedStringHelper.test.d.ts.map +0 -1
- package/dist/tests/filters/SQLTranslatedStringHelper.test.js +0 -491
- package/dist/tests/filters/SQLTranslatedStringHelper.test.js.map +0 -1
- package/dist/tests/filters/dot-syntax.test.d.ts +0 -2
- package/dist/tests/filters/dot-syntax.test.d.ts.map +0 -1
- package/dist/tests/filters/dot-syntax.test.js +0 -210
- package/dist/tests/filters/dot-syntax.test.js.map +0 -1
- package/dist/tests/filters/exists.test.d.ts +0 -2
- package/dist/tests/filters/exists.test.d.ts.map +0 -1
- package/dist/tests/filters/exists.test.js +0 -96
- package/dist/tests/filters/exists.test.js.map +0 -1
- package/dist/tests/filters/joined-relations.test.d.ts +0 -2
- package/dist/tests/filters/joined-relations.test.d.ts.map +0 -1
- package/dist/tests/filters/joined-relations.test.js +0 -167
- package/dist/tests/filters/joined-relations.test.js.map +0 -1
- package/dist/tests/filters/special-cases.test.d.ts +0 -2
- package/dist/tests/filters/special-cases.test.d.ts.map +0 -1
- package/dist/tests/filters/special-cases.test.js +0 -114
- package/dist/tests/filters/special-cases.test.js.map +0 -1
- package/dist/tests/filters/wildcard.test.d.ts +0 -2
- package/dist/tests/filters/wildcard.test.d.ts.map +0 -1
- package/dist/tests/filters/wildcard.test.js +0 -67
- package/dist/tests/filters/wildcard.test.js.map +0 -1
- package/dist/tests/jest.global.setup.d.ts +0 -3
- package/dist/tests/jest.global.setup.d.ts.map +0 -1
- package/dist/tests/jest.global.setup.js +0 -7
- package/dist/tests/jest.global.setup.js.map +0 -1
- package/dist/tests/jest.setup.d.ts +0 -2
- package/dist/tests/jest.setup.d.ts.map +0 -1
- package/dist/tests/jest.setup.js +0 -5
- package/dist/tests/jest.setup.js.map +0 -1
- package/dist/tests/utils/index.d.ts +0 -57
- package/dist/tests/utils/index.d.ts.map +0 -1
- package/dist/tests/utils/index.js +0 -206
- package/dist/tests/utils/index.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/src/QueryableModel.ts +0 -134
- package/src/SQL.ts +0 -128
- package/src/SQLDelete.ts +0 -73
- package/src/SQLExpression.ts +0 -34
- package/src/SQLExpressions.ts +0 -587
- package/src/SQLInsert.ts +0 -113
- package/src/SQLJsonExpressions.ts +0 -283
- package/src/SQLLogger.ts +0 -82
- package/src/SQLOrderBy.ts +0 -69
- package/src/SQLSelect.ts +0 -520
- package/src/SQLTranslatedStringHelper.ts +0 -40
- package/src/SQLWhere.ts +0 -744
- package/src/filters/SQLSorter.ts +0 -60
- package/src/filters/compilers/equals.ts +0 -73
- package/src/filters/compilers/greater.ts +0 -21
- package/src/filters/compilers/less.ts +0 -20
- /package/dist/{src/SQLExpression.d.ts → SQLExpression.d.ts} +0 -0
- /package/dist/{src/SQLLogger.d.ts → SQLLogger.d.ts} +0 -0
- /package/dist/{src/filters → filters}/compilers/index.d.ts +0 -0
package/src/filters/SQLSorter.ts
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { PlainObject } from '@simonbackx/simple-encoding';
|
|
2
|
-
import { SortDefinition, SortList } from '@stamhoofd/structures';
|
|
3
|
-
|
|
4
|
-
import { SimpleError } from '@simonbackx/simple-errors';
|
|
5
|
-
import { SQLExpression } from '../SQLExpression.js';
|
|
6
|
-
import { SQLJoin } from '../SQLJoin.js';
|
|
7
|
-
import { SQLOrderBy, SQLOrderByDirection } from '../SQLOrderBy.js';
|
|
8
|
-
import { SQLSelect } from '../SQLSelect.js';
|
|
9
|
-
|
|
10
|
-
export type SQLSortDefinition<T, B extends PlainObject | Date = PlainObject | Date> = SortDefinition<T, B> & {
|
|
11
|
-
toSQL(direction: SQLOrderByDirection): SQLOrderBy;
|
|
12
|
-
join?: SQLJoin;
|
|
13
|
-
select?: (SQLExpression | string)[];
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type SQLSortDefinitions<T = any> = Record<string, SQLSortDefinition<T>>;
|
|
17
|
-
|
|
18
|
-
export function applySQLSorter(selectQuery: SQLSelect<any>, sortBy: SortList, definitions: SQLSortDefinitions) {
|
|
19
|
-
if (sortBy.length === 0) {
|
|
20
|
-
throw new SimpleError({
|
|
21
|
-
code: 'empty_sort',
|
|
22
|
-
message: 'No sort passed',
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
for (const s of sortBy) {
|
|
27
|
-
const d = definitions[s.key];
|
|
28
|
-
if (!d) {
|
|
29
|
-
throw new Error('Unknown sort key ' + s.key);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
selectQuery.orderBy(d.toSQL(s.order));
|
|
33
|
-
|
|
34
|
-
if (d.join) {
|
|
35
|
-
// Check if no overlap in alias/table (otherwise we'll get issues)
|
|
36
|
-
if (selectQuery._joins.find(j => j === d.join)) {
|
|
37
|
-
// Already added
|
|
38
|
-
}
|
|
39
|
-
else {
|
|
40
|
-
const name = d.join.table.getSQL({ defaultNamespace: 'default' });
|
|
41
|
-
|
|
42
|
-
for (const j of selectQuery._joins) {
|
|
43
|
-
if (j.table.getSQL({ defaultNamespace: 'default' }) === name) {
|
|
44
|
-
throw new SimpleError({
|
|
45
|
-
code: 'sorter_join_overlap',
|
|
46
|
-
message: 'This combination of sorters is not possible',
|
|
47
|
-
human: $t('%GU'),
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
selectQuery.join(d.join);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
if (d.select) {
|
|
57
|
-
selectQuery.select(...d.select);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
|
|
2
|
-
import { scalarToSQLExpression, SQLLower, SQLNull } from '../../SQLExpressions.js';
|
|
3
|
-
import { SQLJsonContains, SQLJsonSearch, SQLJsonValue } from '../../SQLJsonExpressions.js';
|
|
4
|
-
import { SQLWhere, SQLWhereEqual, SQLWhereLike, SQLWhereOr, SQLWhereSign } from '../../SQLWhere.js';
|
|
5
|
-
import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner, SQLValueType } from '../SQLFilter.js';
|
|
6
|
-
import { isJSONColumn } from '../helpers/isJSONColumn.js';
|
|
7
|
-
import { normalizeCompareValue } from '../helpers/normalizeCompareValue.js';
|
|
8
|
-
|
|
9
|
-
export function $equalsSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
|
|
10
|
-
return (originalColumn: SQLCurrentColumn) => {
|
|
11
|
-
const v = assertFilterCompareValue(filter);
|
|
12
|
-
const column = normalizeColumn(originalColumn, v);
|
|
13
|
-
const value = normalizeCompareValue(v, column.type);
|
|
14
|
-
/**
|
|
15
|
-
* Special case, checking for equality with a JSON array.
|
|
16
|
-
* This should return true if the JSON array contains the value exactly.
|
|
17
|
-
*
|
|
18
|
-
* This differs from $contains, which will check for 'LIKE' inside the JSON array.
|
|
19
|
-
*/
|
|
20
|
-
if (column.type === SQLValueType.JSONArray) {
|
|
21
|
-
let where: SQLWhere;
|
|
22
|
-
|
|
23
|
-
if (typeof value === 'string') {
|
|
24
|
-
where = new SQLWhereEqual(
|
|
25
|
-
new SQLJsonSearch(
|
|
26
|
-
new SQLLower(column.expression),
|
|
27
|
-
'one',
|
|
28
|
-
scalarToSQLExpression(
|
|
29
|
-
SQLWhereLike.escape(value),
|
|
30
|
-
),
|
|
31
|
-
),
|
|
32
|
-
SQLWhereSign.NotEqual,
|
|
33
|
-
new SQLNull(),
|
|
34
|
-
);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
where = new SQLJsonContains(
|
|
38
|
-
column.expression,
|
|
39
|
-
scalarToSQLExpression(JSON.stringify(value)),
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// If comparing against null, also check for native MySQL null (the column does not exist)
|
|
44
|
-
if (value === null) {
|
|
45
|
-
where = new SQLWhereOr([
|
|
46
|
-
where,
|
|
47
|
-
new SQLWhereEqual(
|
|
48
|
-
column.expression,
|
|
49
|
-
SQLWhereSign.Equal,
|
|
50
|
-
new SQLNull(),
|
|
51
|
-
),
|
|
52
|
-
]);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return where;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
if (value === null && isJSONColumn(column)) {
|
|
59
|
-
// JSON values can either resolve to null or "null" in MySQL.
|
|
60
|
-
return new SQLWhereEqual(
|
|
61
|
-
new SQLJsonValue(column.expression), // casts json null to null, including invalid paths
|
|
62
|
-
SQLWhereSign.Equal,
|
|
63
|
-
new SQLNull(),
|
|
64
|
-
);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
return new SQLWhereEqual(
|
|
68
|
-
column.expression,
|
|
69
|
-
SQLWhereSign.Equal,
|
|
70
|
-
scalarToSQLExpression(value),
|
|
71
|
-
).setNullable(column.nullable);
|
|
72
|
-
};
|
|
73
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
|
|
2
|
-
import { scalarToSQLExpression } from '../../SQLExpressions.js';
|
|
3
|
-
import { SQLWhereEqual, SQLWhereSign } from '../../SQLWhere.js';
|
|
4
|
-
import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner } from '../SQLFilter.js';
|
|
5
|
-
import { normalizeCompareValue } from '../helpers/normalizeCompareValue.js';
|
|
6
|
-
|
|
7
|
-
export function $greaterThanSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
|
|
8
|
-
return (originalColumn: SQLCurrentColumn) => {
|
|
9
|
-
const v = assertFilterCompareValue(filter);
|
|
10
|
-
const column = normalizeColumn(originalColumn, v);
|
|
11
|
-
const value = normalizeCompareValue(v, column.type);
|
|
12
|
-
|
|
13
|
-
const base = new SQLWhereEqual(
|
|
14
|
-
column.expression,
|
|
15
|
-
SQLWhereSign.Greater,
|
|
16
|
-
scalarToSQLExpression(value),
|
|
17
|
-
).setNullable(column.nullable);
|
|
18
|
-
|
|
19
|
-
return base;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
|
|
2
|
-
import { scalarToSQLExpression } from '../../SQLExpressions.js';
|
|
3
|
-
import { SQLWhereEqual, SQLWhereSign } from '../../SQLWhere.js';
|
|
4
|
-
import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner } from '../SQLFilter.js';
|
|
5
|
-
import { normalizeCompareValue } from '../helpers/normalizeCompareValue.js';
|
|
6
|
-
|
|
7
|
-
export function $lessThanSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
|
|
8
|
-
return (originalColumn: SQLCurrentColumn) => {
|
|
9
|
-
const v = assertFilterCompareValue(filter);
|
|
10
|
-
const column = normalizeColumn(originalColumn, v);
|
|
11
|
-
const value = normalizeCompareValue(v, column.type);
|
|
12
|
-
|
|
13
|
-
const base = new SQLWhereEqual(
|
|
14
|
-
column.expression,
|
|
15
|
-
SQLWhereSign.Less,
|
|
16
|
-
scalarToSQLExpression(value),
|
|
17
|
-
).setNullable(column.nullable);
|
|
18
|
-
return base;
|
|
19
|
-
};
|
|
20
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|