@stamhoofd/sql 2.115.1 → 2.117.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.
Files changed (132) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +1 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/ModelCache.d.ts +13 -0
  6. package/dist/src/ModelCache.d.ts.map +1 -0
  7. package/dist/src/ModelCache.js +57 -0
  8. package/dist/src/ModelCache.js.map +1 -0
  9. package/dist/src/QueryableModel.d.ts +21 -7
  10. package/dist/src/QueryableModel.d.ts.map +1 -1
  11. package/dist/src/QueryableModel.js +56 -7
  12. package/dist/src/QueryableModel.js.map +1 -1
  13. package/dist/src/SQLExpressions.js +1 -1
  14. package/dist/src/SQLExpressions.js.map +1 -1
  15. package/dist/src/SQLJoin.d.ts +9 -9
  16. package/dist/src/SQLJoin.d.ts.map +1 -1
  17. package/dist/src/SQLJoin.js +7 -7
  18. package/dist/src/SQLJoin.js.map +1 -1
  19. package/dist/src/SQLJsonExpressions.d.ts +3 -3
  20. package/dist/src/SQLJsonExpressions.d.ts.map +1 -1
  21. package/dist/src/SQLJsonExpressions.js +21 -21
  22. package/dist/src/SQLJsonExpressions.js.map +1 -1
  23. package/dist/src/SQLLogger.d.ts +2 -1
  24. package/dist/src/SQLLogger.d.ts.map +1 -1
  25. package/dist/src/SQLLogger.js +16 -3
  26. package/dist/src/SQLLogger.js.map +1 -1
  27. package/dist/src/SQLOrderBy.d.ts +3 -3
  28. package/dist/src/SQLOrderBy.d.ts.map +1 -1
  29. package/dist/src/SQLOrderBy.js +6 -6
  30. package/dist/src/SQLOrderBy.js.map +1 -1
  31. package/dist/src/SQLSelect.d.ts +1 -0
  32. package/dist/src/SQLSelect.d.ts.map +1 -1
  33. package/dist/src/SQLSelect.js +3 -0
  34. package/dist/src/SQLSelect.js.map +1 -1
  35. package/dist/src/SQLWhere.d.ts +4 -4
  36. package/dist/src/SQLWhere.d.ts.map +1 -1
  37. package/dist/src/SQLWhere.js +26 -26
  38. package/dist/src/SQLWhere.js.map +1 -1
  39. package/dist/src/filters/SQLFilter.d.ts +4 -4
  40. package/dist/src/filters/SQLFilter.d.ts.map +1 -1
  41. package/dist/src/filters/SQLFilter.js +26 -23
  42. package/dist/src/filters/SQLFilter.js.map +1 -1
  43. package/dist/src/filters/compilers/contains.d.ts +1 -1
  44. package/dist/src/filters/compilers/contains.d.ts.map +1 -1
  45. package/dist/src/filters/compilers/contains.js +10 -10
  46. package/dist/src/filters/compilers/contains.js.map +1 -1
  47. package/dist/src/filters/compilers/equals.d.ts +1 -1
  48. package/dist/src/filters/compilers/equals.d.ts.map +1 -1
  49. package/dist/src/filters/compilers/equals.js +17 -17
  50. package/dist/src/filters/compilers/equals.js.map +1 -1
  51. package/dist/src/filters/compilers/greater.d.ts +1 -1
  52. package/dist/src/filters/compilers/greater.d.ts.map +1 -1
  53. package/dist/src/filters/compilers/greater.js +7 -7
  54. package/dist/src/filters/compilers/greater.js.map +1 -1
  55. package/dist/src/filters/compilers/in.d.ts +1 -1
  56. package/dist/src/filters/compilers/in.d.ts.map +1 -1
  57. package/dist/src/filters/compilers/in.js +16 -16
  58. package/dist/src/filters/compilers/in.js.map +1 -1
  59. package/dist/src/filters/compilers/index.d.ts +4 -4
  60. package/dist/src/filters/compilers/index.d.ts.map +1 -1
  61. package/dist/src/filters/compilers/index.js +4 -4
  62. package/dist/src/filters/compilers/index.js.map +1 -1
  63. package/dist/src/filters/compilers/less.d.ts +1 -1
  64. package/dist/src/filters/compilers/less.d.ts.map +1 -1
  65. package/dist/src/filters/compilers/less.js +7 -7
  66. package/dist/src/filters/compilers/less.js.map +1 -1
  67. package/dist/src/filters/helpers/isJSONColumn.d.ts +1 -1
  68. package/dist/src/filters/helpers/isJSONColumn.d.ts.map +1 -1
  69. package/dist/src/filters/helpers/isJSONColumn.js +6 -6
  70. package/dist/src/filters/helpers/isJSONColumn.js.map +1 -1
  71. package/dist/src/filters/helpers/normalizeCompareValue.d.ts +1 -1
  72. package/dist/src/filters/helpers/normalizeCompareValue.d.ts.map +1 -1
  73. package/dist/src/filters/helpers/normalizeCompareValue.js +14 -14
  74. package/dist/src/filters/helpers/normalizeCompareValue.js.map +1 -1
  75. package/dist/tests/filters/$and.test.js +31 -31
  76. package/dist/tests/filters/$and.test.js.map +1 -1
  77. package/dist/tests/filters/$contains.test.js +45 -45
  78. package/dist/tests/filters/$contains.test.js.map +1 -1
  79. package/dist/tests/filters/$eq.test.js +88 -88
  80. package/dist/tests/filters/$eq.test.js.map +1 -1
  81. package/dist/tests/filters/$gt.test.js +32 -32
  82. package/dist/tests/filters/$gt.test.js.map +1 -1
  83. package/dist/tests/filters/$gte.test.js +26 -26
  84. package/dist/tests/filters/$gte.test.js.map +1 -1
  85. package/dist/tests/filters/$in.test.js +45 -45
  86. package/dist/tests/filters/$in.test.js.map +1 -1
  87. package/dist/tests/filters/$lt.test.js +26 -26
  88. package/dist/tests/filters/$lt.test.js.map +1 -1
  89. package/dist/tests/filters/$lte.test.js +26 -26
  90. package/dist/tests/filters/$lte.test.js.map +1 -1
  91. package/dist/tests/filters/$neq.test.js +6 -6
  92. package/dist/tests/filters/$neq.test.js.map +1 -1
  93. package/dist/tests/filters/$not.test.js +9 -9
  94. package/dist/tests/filters/$not.test.js.map +1 -1
  95. package/dist/tests/filters/$or.test.js +25 -25
  96. package/dist/tests/filters/$or.test.js.map +1 -1
  97. package/dist/tests/filters/SQLTranslatedStringHelper.test.js +50 -50
  98. package/dist/tests/filters/SQLTranslatedStringHelper.test.js.map +1 -1
  99. package/dist/tests/filters/dot-syntax.test.js +20 -20
  100. package/dist/tests/filters/dot-syntax.test.js.map +1 -1
  101. package/dist/tests/filters/exists.test.js +26 -36
  102. package/dist/tests/filters/exists.test.js.map +1 -1
  103. package/dist/tests/filters/joined-relations.test.js +43 -43
  104. package/dist/tests/filters/joined-relations.test.js.map +1 -1
  105. package/dist/tests/filters/special-cases.test.js +19 -19
  106. package/dist/tests/filters/special-cases.test.js.map +1 -1
  107. package/dist/tests/filters/wildcard.test.js +12 -12
  108. package/dist/tests/filters/wildcard.test.js.map +1 -1
  109. package/dist/tests/utils/index.d.ts +3 -3
  110. package/dist/tests/utils/index.d.ts.map +1 -1
  111. package/dist/tests/utils/index.js +12 -12
  112. package/dist/tests/utils/index.js.map +1 -1
  113. package/dist/tsconfig.tsbuildinfo +1 -1
  114. package/package.json +4 -3
  115. package/src/ModelCache.ts +61 -0
  116. package/src/QueryableModel.ts +71 -8
  117. package/src/SQLExpressions.ts +1 -1
  118. package/src/SQLJoin.ts +3 -3
  119. package/src/SQLJsonExpressions.ts +3 -3
  120. package/src/SQLLogger.ts +18 -3
  121. package/src/SQLOrderBy.ts +4 -4
  122. package/src/SQLSelect.ts +5 -0
  123. package/src/SQLWhere.ts +5 -5
  124. package/src/filters/SQLFilter.ts +11 -8
  125. package/src/filters/compilers/contains.ts +5 -5
  126. package/src/filters/compilers/equals.ts +6 -6
  127. package/src/filters/compilers/greater.ts +4 -4
  128. package/src/filters/compilers/in.ts +6 -6
  129. package/src/filters/compilers/index.ts +4 -4
  130. package/src/filters/compilers/less.ts +4 -4
  131. package/src/filters/helpers/isJSONColumn.ts +1 -1
  132. package/src/filters/helpers/normalizeCompareValue.ts +1 -1
@@ -1,20 +1,33 @@
1
1
  import { Model, SQLResultNamespacedRow } from '@simonbackx/simple-database';
2
- import { SQLSelect } from './SQLSelect';
3
- import { SQL } from './SQL';
4
- import { SQLDelete } from './SQLDelete';
5
- import { SQLUpdate } from './SQLUpdate';
6
- import { SQLInsert } from './SQLInsert';
7
- import { SQLExpression } from './SQLExpression';
2
+ import { SQLSelect } from './SQLSelect.js';
3
+ import { SQL } from './SQL.js';
4
+ import { SQLDelete } from './SQLDelete.js';
5
+ import { SQLUpdate } from './SQLUpdate.js';
6
+ import { SQLInsert } from './SQLInsert.js';
7
+ import { SQLExpression } from './SQLExpression.js';
8
+ import { ModelCache } from './ModelCache.js';
8
9
 
9
10
  export class QueryableModel extends Model {
10
- static select<T extends typeof Model>(this: T, ...columns: (SQLExpression | string)[]): SQLSelect<InstanceType<T>> {
11
+ rawSelectedRow: SQLResultNamespacedRow | null = null;
12
+ static cache: ModelCache<QueryableModel> | null = null;
13
+
14
+ static select<T extends typeof Model & typeof QueryableModel>(this: T, ...columns: (SQLExpression | string)[]): SQLSelect<InstanceType<T>> {
11
15
  const transformer = (row: SQLResultNamespacedRow): InstanceType<T> => {
12
- const d = (this as T).fromRow(row[this.table] as any) as InstanceType<T> | undefined;
16
+ const d = (this as T).fromRow(row[this.table]) as InstanceType<T> | undefined;
17
+
18
+ if (this.cache && d) {
19
+ this.cache.store(d);
20
+ }
21
+
22
+ // If there are any other namespaces, include it as metadata
13
23
 
14
24
  if (!d) {
15
25
  console.error('Could not transform row', row, 'into model', this.table, 'check if the primary key is returned in the query');
16
26
  throw new Error('Missing data for model ' + this.table);
17
27
  }
28
+ if (d instanceof QueryableModel) {
29
+ d.rawSelectedRow = row;
30
+ }
18
31
 
19
32
  return d;
20
33
  };
@@ -68,4 +81,54 @@ export class QueryableModel extends Model {
68
81
  }
69
82
  }
70
83
  }
84
+
85
+ /**
86
+ * Get a model by its primary key
87
+ * @param id primary key
88
+ */
89
+ static override async getByID<T extends typeof Model>(this: T & typeof QueryableModel, id: number | string, required: true): Promise<InstanceType<T>>;
90
+ static override async getByID<T extends typeof Model>(this: T & typeof QueryableModel, id: number | string): Promise<InstanceType<T> | undefined>;
91
+ static override async getByID<T extends typeof Model>(this: T & typeof QueryableModel, id: number | string, required?: boolean): Promise<InstanceType<T> | undefined> {
92
+ if (this.cache) {
93
+ const hit = this.cache.getById(id);
94
+ if (hit) {
95
+ console.log('Cache hit, get by id', this.name, id);
96
+ return hit as InstanceType<T>;
97
+ }
98
+ }
99
+ return ((await (this as any as typeof QueryableModel).select().where(this.primary.name, id).first(required ?? false)) ?? undefined) as any as InstanceType<T> | undefined;
100
+ }
101
+
102
+ /**
103
+ * Get multiple models by their ID
104
+ * @param ids primary key of the models you want to fetch
105
+ */
106
+ static override async getByIDs<T extends typeof Model>(this: T & typeof QueryableModel, ...ids: (number | string)[]): Promise<InstanceType<T>[]> {
107
+ if (ids.length === 0) {
108
+ return [];
109
+ }
110
+
111
+ if (this.cache) {
112
+ const hits: InstanceType<T>[] = [];
113
+ const remaining: (number | string)[] = [];
114
+ for (const id of ids) {
115
+ const hit = this.cache.getById(id);
116
+ if (hit) {
117
+ console.log('Cache hit, get by id', this.name, id);
118
+ hits.push(hit as InstanceType<T>);
119
+ }
120
+ else {
121
+ remaining.push(id);
122
+ }
123
+ }
124
+ ids = remaining;
125
+ if (remaining.length === 0) {
126
+ return hits;
127
+ }
128
+ const fetched = await (this as any as typeof QueryableModel).select().where(this.primary.name, ids).limit(ids.length).fetch() as any as InstanceType<T>[];
129
+ return [...fetched, ...hits];
130
+ }
131
+
132
+ return (this as any as typeof QueryableModel).select().where(this.primary.name, ids).limit(ids.length).fetch() as any as InstanceType<T>[];
133
+ }
71
134
  }
@@ -37,7 +37,7 @@ export class SQLDistinct implements SQLExpression {
37
37
 
38
38
  getSQL(options?: SQLExpressionOptions): SQLQuery {
39
39
  return joinSQLQuery([
40
- 'DISTINCT',
40
+ 'DISTINCT ',
41
41
  this.expression.getSQL(options),
42
42
  ]);
43
43
  }
package/src/SQLJoin.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { SQLExpression, SQLExpressionOptions, SQLNamedExpression, SQLQuery, joinSQLQuery } from './SQLExpression';
2
- import { SQLSelect } from './SQLSelect';
3
- import { Whereable } from './SQLWhere';
1
+ import { SQLExpression, SQLExpressionOptions, SQLNamedExpression, SQLQuery, joinSQLQuery } from './SQLExpression.js';
2
+ import { SQLSelect } from './SQLSelect.js';
3
+ import { Whereable } from './SQLWhere.js';
4
4
 
5
5
  export enum SQLJoinType {
6
6
  Left = 'Left',
@@ -1,6 +1,6 @@
1
- import { SQLExpression, SQLExpressionOptions, SQLQuery, joinSQLQuery } from './SQLExpression';
2
- import { SQLJSONFalse, SQLJSONNull, SQLJSONTrue, SQLSafeValue, SQLScalar, SQLScalarValue } from './SQLExpressions';
3
- import { SQLWhere } from './SQLWhere';
1
+ import { SQLExpression, SQLExpressionOptions, SQLQuery, joinSQLQuery } from './SQLExpression.js';
2
+ import { SQLJSONFalse, SQLJSONNull, SQLJSONTrue, SQLSafeValue, SQLScalar, SQLScalarValue } from './SQLExpressions.js';
3
+ import { SQLWhere } from './SQLWhere.js';
4
4
 
5
5
  export function scalarToSQLJSONExpression(s: SQLScalarValue | null): SQLExpression {
6
6
  if (s === null) {
package/src/SQLLogger.ts CHANGED
@@ -4,6 +4,7 @@ import { StyledText } from '@simonbackx/simple-logging';
4
4
  class StaticSQLLogger {
5
5
  slowQueryThresholdMs: number | null = null;
6
6
  explainAllAndLogInefficient = false;
7
+ customLoggers: ((query: string, params: any[], elapsedTimeMs: number) => void)[] = [];
7
8
 
8
9
  async explain(query: string, params: any[]) {
9
10
  // Run an EXPLAIN on the query to see what is going on
@@ -18,14 +19,19 @@ class StaticSQLLogger {
18
19
  return null;
19
20
  }
20
21
 
21
- async logInefficientExplainResult(query: string, params: any[], explainResult: any) {
22
+ async logInefficientExplainResult(query: string, params: any[], explainResult: any, elapsedTimeMs?: number) {
22
23
  if (!explainResult) {
23
24
  return;
24
25
  }
26
+ if (elapsedTimeMs !== undefined && elapsedTimeMs < 20) {
27
+ // Probably fine
28
+ return;
29
+ }
30
+
25
31
  if (explainResult['type'] === 'ALL') {
26
32
  console.warn(
27
33
  new StyledText('[FULL TABLE SCAN] ').addClass('error').addTag('query'),
28
- 'Inefficient query detected:',
34
+ `Inefficient query detected${elapsedTimeMs !== undefined ? ' (' + elapsedTimeMs.toFixed(0) + 'ms)' : ''}:`,
29
35
  query,
30
36
  params,
31
37
  'EXPLAIN result:',
@@ -55,8 +61,17 @@ class StaticSQLLogger {
55
61
  console.trace('Slow SQL query (' + elapsedTimeMs.toFixed(2) + 'ms)\nQuery: ' + query, params);
56
62
  }
57
63
 
64
+ for (const logger of this.customLoggers) {
65
+ try {
66
+ logger(query, params, elapsedTimeMs);
67
+ }
68
+ catch (e) {
69
+ console.error('Error in custom SQL logger', e);
70
+ }
71
+ }
72
+
58
73
  if (this.explainAllAndLogInefficient) {
59
- await this.logInefficientExplainResult(query, params, await this.explain(query, params));
74
+ await this.logInefficientExplainResult(query, params, await this.explain(query, params), elapsedTimeMs);
60
75
  return result;
61
76
  }
62
77
 
package/src/SQLOrderBy.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { SQLExpression, SQLExpressionOptions, SQLQuery, joinSQLQuery } from './SQLExpression';
2
- import { SQLColumnExpression } from './SQLExpressions';
1
+ import { SQLExpression, SQLExpressionOptions, SQLQuery, joinSQLQuery } from './SQLExpression.js';
2
+ import { SQLColumnExpression } from './SQLExpressions.js';
3
3
 
4
- type Constructor<T = {}> = new (...args: any[]) => T;
4
+ type Constructor<T = object> = new (...args: any[]) => T;
5
5
 
6
- export function Orderable<Sup extends Constructor<{}>>(Base: Sup) {
6
+ export function Orderable<Sup extends Constructor<object>>(Base: Sup) {
7
7
  return class extends Base {
8
8
  _orderBy: SQLOrderBy | null = null;
9
9
 
package/src/SQLSelect.ts CHANGED
@@ -98,6 +98,10 @@ export class SQLSelect<T extends object = SQLResultNamespacedRow> extends Wherea
98
98
  }
99
99
 
100
100
  getSQL(options?: SQLExpressionOptions): SQLQuery {
101
+ if (!this._from) {
102
+ throw new Error('Forgot to define .from(...) for SQLSelect');
103
+ }
104
+
101
105
  const query: SQLQuery[] = [
102
106
  'SELECT',
103
107
  ];
@@ -229,6 +233,7 @@ export class SQLSelect<T extends object = SQLResultNamespacedRow> extends Wherea
229
233
 
230
234
  first(required: false): Promise<T | null>;
231
235
  first(required: true): Promise<T>;
236
+ first(required: boolean): Promise<T | null>;
232
237
  async first(required = true): Promise<T | null> {
233
238
  const rows = await this.limit(1).fetch();
234
239
  if (rows.length === 0) {
package/src/SQLWhere.ts CHANGED
@@ -1,9 +1,9 @@
1
- import { SQLExpression, SQLExpressionOptions, SQLQuery, joinSQLQuery, normalizeSQLQuery } from './SQLExpression';
2
- import { SQLArray, SQLColumnExpression, SQLDynamicExpression, SQLNull, readDynamicSQLExpression } from './SQLExpressions';
3
- import { SQLJoin, SQLJoinType } from './SQLJoin';
4
- import { SQLSelect } from './SQLSelect';
1
+ import { SQLExpression, SQLExpressionOptions, SQLQuery, joinSQLQuery, normalizeSQLQuery } from './SQLExpression.js';
2
+ import { SQLArray, SQLColumnExpression, SQLDynamicExpression, SQLNull, readDynamicSQLExpression } from './SQLExpressions.js';
3
+ import { SQLJoin, SQLJoinType } from './SQLJoin.js';
4
+ import { SQLSelect } from './SQLSelect.js';
5
5
 
6
- type Constructor<T = {}> = new (...args: any[]) => T;
6
+ type Constructor<T = object> = new (...args: any[]) => T;
7
7
 
8
8
  export enum SQLWhereSign {
9
9
  Equal = '=',
@@ -1,12 +1,13 @@
1
1
  import { SimpleError } from '@simonbackx/simple-errors';
2
2
  import { compileFilter, FilterCompiler, FilterDefinitions, filterDefinitionsToCompiler, RequiredFilterCompiler, StamhoofdFilter } from '@stamhoofd/structures';
3
- import { SQLExpression, SQLExpressionOptions, SQLQuery } from '../SQLExpression';
4
- import { SQLJoin } from '../SQLJoin';
5
- import { SQLJsonValue } from '../SQLJsonExpressions';
6
- import { SQLSelect } from '../SQLSelect';
7
- import { SQLWhere, SQLWhereAnd, SQLWhereExists, SQLWhereJoin, SQLWhereNot, SQLWhereOr } from '../SQLWhere';
8
- import { $equalsSQLFilterCompiler, $greaterThanSQLFilterCompiler, $inSQLFilterCompiler, $lessThanSQLFilterCompiler } from './compilers';
9
- import { $containsSQLFilterCompiler } from './compilers/contains';
3
+ import { SQLExpression, SQLExpressionOptions, SQLQuery } from '../SQLExpression.js';
4
+ import { SQLJoin } from '../SQLJoin.js';
5
+ import { SQLJsonValue } from '../SQLJsonExpressions.js';
6
+ import { SQLSelect } from '../SQLSelect.js';
7
+ import { SQLWhere, SQLWhereAnd, SQLWhereExists, SQLWhereJoin, SQLWhereNot, SQLWhereOr } from '../SQLWhere.js';
8
+ import { $equalsSQLFilterCompiler, $greaterThanSQLFilterCompiler, $inSQLFilterCompiler, $lessThanSQLFilterCompiler } from './compilers/index.js';
9
+ import { $containsSQLFilterCompiler } from './compilers/contains.js';
10
+ import { SQLSafeValue } from '../SQLExpressions.js';
10
11
 
11
12
  export type SQLSyncFilterRunner = (column: SQLCurrentColumn) => SQLWhere;
12
13
  export type SQLFilterRunner = (column: SQLCurrentColumn) => Promise<SQLWhere> | SQLWhere;
@@ -123,7 +124,9 @@ export function createExistsFilter(baseSelect: InstanceType<typeof SQLSelect> &
123
124
  type: SQLValueType.Table,
124
125
  nullable: false,
125
126
  });
126
- const q = baseSelect.clone().andWhere(w);
127
+ const q = baseSelect.clone();
128
+ q._columns = [new SQLSafeValue(1)];
129
+ q.andWhere(w);
127
130
  return new SQLWhereExists(q);
128
131
  };
129
132
  };
@@ -1,10 +1,10 @@
1
1
  import { SimpleError } from '@simonbackx/simple-errors';
2
2
  import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
3
- import { scalarToSQLExpression, SQLLower, SQLNull } from '../../SQLExpressions';
4
- import { SQLJsonSearch } from '../../SQLJsonExpressions';
5
- import { SQLWhereEqual, SQLWhereLike, SQLWhereSign } from '../../SQLWhere';
6
- import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner, SQLValueType } from '../SQLFilter';
7
- import { normalizeCompareValue } from '../helpers/normalizeCompareValue';
3
+ import { scalarToSQLExpression, SQLLower, SQLNull } from '../../SQLExpressions.js';
4
+ import { SQLJsonSearch } from '../../SQLJsonExpressions.js';
5
+ import { SQLWhereEqual, SQLWhereLike, SQLWhereSign } from '../../SQLWhere.js';
6
+ import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner, SQLValueType } from '../SQLFilter.js';
7
+ import { normalizeCompareValue } from '../helpers/normalizeCompareValue.js';
8
8
 
9
9
  export function $containsSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
10
10
  return (originalColumn: SQLCurrentColumn) => {
@@ -1,10 +1,10 @@
1
1
  import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
2
- import { scalarToSQLExpression, SQLLower, SQLNull } from '../../SQLExpressions';
3
- import { SQLJsonContains, SQLJsonSearch, SQLJsonValue } from '../../SQLJsonExpressions';
4
- import { SQLWhere, SQLWhereEqual, SQLWhereLike, SQLWhereOr, SQLWhereSign } from '../../SQLWhere';
5
- import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner, SQLValueType } from '../SQLFilter';
6
- import { isJSONColumn } from '../helpers/isJSONColumn';
7
- import { normalizeCompareValue } from '../helpers/normalizeCompareValue';
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
8
 
9
9
  export function $equalsSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
10
10
  return (originalColumn: SQLCurrentColumn) => {
@@ -1,8 +1,8 @@
1
1
  import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
2
- import { scalarToSQLExpression } from '../../SQLExpressions';
3
- import { SQLWhereEqual, SQLWhereSign } from '../../SQLWhere';
4
- import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner } from '../SQLFilter';
5
- import { normalizeCompareValue } from '../helpers/normalizeCompareValue';
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
6
 
7
7
  export function $greaterThanSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
8
8
  return (originalColumn: SQLCurrentColumn) => {
@@ -1,11 +1,11 @@
1
1
  import { SimpleError } from '@simonbackx/simple-errors';
2
2
  import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
3
- import { scalarToSQLExpression, SQLArray } from '../../SQLExpressions';
4
- import { SQLJsonOverlaps } from '../../SQLJsonExpressions';
5
- import { SQLWhereEqual, SQLWhereOr, SQLWhereSign } from '../../SQLWhere';
6
- import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner, SQLValueType } from '../SQLFilter';
7
- import { normalizeCompareValue } from '../helpers/normalizeCompareValue';
8
- import { $equalsSQLFilterCompiler } from './equals';
3
+ import { scalarToSQLExpression, SQLArray } from '../../SQLExpressions.js';
4
+ import { SQLJsonOverlaps } from '../../SQLJsonExpressions.js';
5
+ import { SQLWhereEqual, SQLWhereOr, SQLWhereSign } from '../../SQLWhere.js';
6
+ import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner, SQLValueType } from '../SQLFilter.js';
7
+ import { normalizeCompareValue } from '../helpers/normalizeCompareValue.js';
8
+ import { $equalsSQLFilterCompiler } from './equals.js';
9
9
 
10
10
  export function $inSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
11
11
  return (originalColumn: SQLCurrentColumn) => {
@@ -1,4 +1,4 @@
1
- export * from './less';
2
- export * from './greater';
3
- export * from './equals';
4
- export * from './in';
1
+ export * from './less.js';
2
+ export * from './greater.js';
3
+ export * from './equals.js';
4
+ export * from './in.js';
@@ -1,8 +1,8 @@
1
1
  import { assertFilterCompareValue, StamhoofdFilter } from '@stamhoofd/structures';
2
- import { scalarToSQLExpression } from '../../SQLExpressions';
3
- import { SQLWhereEqual, SQLWhereSign } from '../../SQLWhere';
4
- import { normalizeColumn, SQLCurrentColumn, SQLSyncFilterRunner } from '../SQLFilter';
5
- import { normalizeCompareValue } from '../helpers/normalizeCompareValue';
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
6
 
7
7
  export function $lessThanSQLFilterCompiler(filter: StamhoofdFilter): SQLSyncFilterRunner {
8
8
  return (originalColumn: SQLCurrentColumn) => {
@@ -1,4 +1,4 @@
1
- import { SQLCurrentColumn, SQLValueType } from '../SQLFilter';
1
+ import { SQLCurrentColumn, SQLValueType } from '../SQLFilter.js';
2
2
 
3
3
  export function isJSONColumn({ type }: SQLCurrentColumn): boolean {
4
4
  return isJSONType(type);
@@ -1,5 +1,5 @@
1
1
  import { StamhoofdCompareValue } from '@stamhoofd/structures';
2
- import { SQLValueType } from '../SQLFilter';
2
+ import { SQLValueType } from '../SQLFilter.js';
3
3
 
4
4
  /**
5
5
  * Prepares a compare value so we can compare it, given a certain column type.