@travetto/model-sql 8.0.0-alpha.28 → 8.0.0-alpha.29
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/package.json +8 -8
- package/src/dialect.ts +4 -0
- package/support/test/query.ts +4 -0
package/README.md
CHANGED
|
@@ -39,7 +39,7 @@ Supported transaction modes include:
|
|
|
39
39
|
Bulk operations (`processBulk`) batch insert, delete, and update statements for high performance. Bulk updates utilize standard ANSI SQL `CASE ... WHEN` constructs to update multiple records in a single database query across all SQL engines.
|
|
40
40
|
|
|
41
41
|
## Supported Features
|
|
42
|
-
All SQL model service implementations derive from [BaseSQLModelService](https://github.com/travetto/travetto/tree/main/module/model-sql/src/service.ts#
|
|
42
|
+
All SQL model service implementations derive from [BaseSQLModelService](https://github.com/travetto/travetto/tree/main/module/model-sql/src/service.ts#L68) and support:
|
|
43
43
|
* [Bulk](https://github.com/travetto/travetto/tree/main/module/model/src/types/bulk.ts#L60)
|
|
44
44
|
* [CRUD](https://github.com/travetto/travetto/tree/main/module/model/src/types/crud.ts#L10)
|
|
45
45
|
* [Expiry](https://github.com/travetto/travetto/tree/main/module/model/src/types/expiry.ts#L10)
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-sql",
|
|
3
|
-
"version": "8.0.0-alpha.
|
|
3
|
+
"version": "8.0.0-alpha.29",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "SQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
|
|
6
6
|
"keywords": [
|
|
@@ -28,15 +28,15 @@
|
|
|
28
28
|
"directory": "module/model-sql"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@travetto/config": "^8.0.0-alpha.
|
|
32
|
-
"@travetto/context": "^8.0.0-alpha.
|
|
33
|
-
"@travetto/model": "^8.0.0-alpha.
|
|
34
|
-
"@travetto/model-indexed": "^8.0.0-alpha.
|
|
35
|
-
"@travetto/model-query": "^8.0.0-alpha.
|
|
31
|
+
"@travetto/config": "^8.0.0-alpha.24",
|
|
32
|
+
"@travetto/context": "^8.0.0-alpha.22",
|
|
33
|
+
"@travetto/model": "^8.0.0-alpha.25",
|
|
34
|
+
"@travetto/model-indexed": "^8.0.0-alpha.27",
|
|
35
|
+
"@travetto/model-query": "^8.0.0-alpha.27"
|
|
36
36
|
},
|
|
37
37
|
"peerDependencies": {
|
|
38
|
-
"@travetto/cli": "^8.0.0-alpha.
|
|
39
|
-
"@travetto/test": "^8.0.0-alpha.
|
|
38
|
+
"@travetto/cli": "^8.0.0-alpha.30",
|
|
39
|
+
"@travetto/test": "^8.0.0-alpha.23"
|
|
40
40
|
},
|
|
41
41
|
"peerDependenciesMeta": {
|
|
42
42
|
"@travetto/cli": {
|
package/src/dialect.ts
CHANGED
|
@@ -68,6 +68,7 @@ export abstract class AbstractANSI99Dialect {
|
|
|
68
68
|
abstract compileArrayEquals(context: ResolvedPathContext, identifier: string, values: unknown): { sql: string; formatted: unknown };
|
|
69
69
|
abstract compileArrayAny(context: ResolvedPathContext, identifier: string, values: unknown[]): { sql: string; formatted: unknown };
|
|
70
70
|
abstract compileArrayExists(context: ResolvedPathContext, identifier?: string): { sql: string };
|
|
71
|
+
abstract compileArrayRegex(context: ResolvedPathContext, identifier: string, value: RegExp | string): { sql: string; formatted: unknown };
|
|
71
72
|
|
|
72
73
|
abstract getRegexOperator(caseInsensitive: boolean): string;
|
|
73
74
|
abstract formatRegex(source: string, caseInsensitive: boolean): string;
|
|
@@ -448,6 +449,9 @@ CREATE TABLE ${this.escapeIdentifier(context.tableName)} (
|
|
|
448
449
|
const { sql } = this.compileArrayExists(resolvedContext, identifier);
|
|
449
450
|
const finalSql = !value ? `NOT(${sql})` : sql;
|
|
450
451
|
clause = { sql: finalSql };
|
|
452
|
+
} else if (operator === '$regex') {
|
|
453
|
+
const { sql, formatted } = this.compileArrayRegex(resolvedContext, identifier, value as RegExp | string);
|
|
454
|
+
clause = { sql, parameters: { [identifier]: formatted } };
|
|
451
455
|
} else {
|
|
452
456
|
throw new RuntimeError(`Operator "${operator}" is not supported for arrays`, { category: 'data' });
|
|
453
457
|
}
|
package/support/test/query.ts
CHANGED
|
@@ -66,6 +66,10 @@ class MockDialect extends AbstractANSI99Dialect {
|
|
|
66
66
|
return { sql: `${context.sqlPath} IS NOT NULL`, formatted: undefined };
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
+
compileArrayRegex(context: ResolvedPathContext, identifier: string, value: RegExp | string) {
|
|
70
|
+
return { sql: `${context.sqlPath} REGEX ${identifier}`, formatted: value };
|
|
71
|
+
}
|
|
72
|
+
|
|
69
73
|
getRegexOperator(caseInsensitive: boolean) {
|
|
70
74
|
return caseInsensitive ? '~*' : '~';
|
|
71
75
|
}
|