@travetto/model-mysql 8.0.0-alpha.29 → 8.0.0-alpha.30

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 (2) hide show
  1. package/package.json +7 -7
  2. package/src/dialect.ts +13 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-mysql",
3
- "version": "8.0.0-alpha.29",
3
+ "version": "8.0.0-alpha.30",
4
4
  "type": "module",
5
5
  "description": "MySQL 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-mysql"
29
29
  },
30
30
  "dependencies": {
31
- "@travetto/config": "^8.0.0-alpha.23",
32
- "@travetto/context": "^8.0.0-alpha.21",
33
- "@travetto/model": "^8.0.0-alpha.24",
34
- "@travetto/model-query": "^8.0.0-alpha.26",
35
- "@travetto/model-sql": "^8.0.0-alpha.28",
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-query": "^8.0.0-alpha.27",
35
+ "@travetto/model-sql": "^8.0.0-alpha.29",
36
36
  "mysql2": "^3.23.1"
37
37
  },
38
38
  "peerDependencies": {
39
- "@travetto/cli": "^8.0.0-alpha.29"
39
+ "@travetto/cli": "^8.0.0-alpha.30"
40
40
  },
41
41
  "peerDependenciesMeta": {
42
42
  "@travetto/cli": {
package/src/dialect.ts CHANGED
@@ -118,6 +118,19 @@ export class MysqlDialect extends AbstractANSI99Dialect {
118
118
  return { sql: `(${targetSqlPath} IS NOT NULL AND JSON_LENGTH(${targetSqlPath}) > 0)` };
119
119
  }
120
120
 
121
+ compileArrayRegex(context: ResolvedPathContext, identifier: string, value: RegExp | string): { sql: string; formatted: unknown } {
122
+ const targetSqlPath = this.#getArraySqlPath(context);
123
+ const regex = value instanceof RegExp ? value : new RegExp(String(value));
124
+ const caseInsensitive = regex.flags.includes('i');
125
+ const regexOp = this.getRegexOperator(caseInsensitive);
126
+ const regexSource = this.formatRegex(regex.source, caseInsensitive);
127
+
128
+ return {
129
+ sql: `EXISTS (SELECT 1 FROM JSON_TABLE(${targetSqlPath}, '$[*]' COLUMNS (val VARCHAR(255) PATH '$')) AS jt WHERE jt.val ${regexOp} ${identifier})`,
130
+ formatted: regexSource
131
+ };
132
+ }
133
+
121
134
  compileJsonEquality(sqlPath: string, identifier: string): string {
122
135
  return `CAST(${sqlPath} AS JSON) = CAST(${identifier} AS JSON)`;
123
136
  }