@travetto/model-sql 3.1.14 → 3.2.0-rc.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 (2) hide show
  1. package/package.json +7 -7
  2. package/src/dialect/base.ts +15 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/model-sql",
3
- "version": "3.1.14",
3
+ "version": "3.2.0-rc.0",
4
4
  "description": "SQL backing for the travetto model module, with real-time modeling support for SQL schemas.",
5
5
  "keywords": [
6
6
  "sql",
@@ -27,14 +27,14 @@
27
27
  "directory": "module/model-sql"
28
28
  },
29
29
  "dependencies": {
30
- "@travetto/config": "^3.1.8",
31
- "@travetto/context": "^3.1.4",
32
- "@travetto/model": "^3.1.14",
33
- "@travetto/model-query": "^3.1.14"
30
+ "@travetto/config": "^3.2.0-rc.0",
31
+ "@travetto/context": "^3.2.0-rc.0",
32
+ "@travetto/model": "^3.2.0-rc.0",
33
+ "@travetto/model-query": "^3.2.0-rc.0"
34
34
  },
35
35
  "peerDependencies": {
36
- "@travetto/command": "^3.1.4",
37
- "@travetto/test": "^3.1.5"
36
+ "@travetto/command": "^3.2.0-rc.0",
37
+ "@travetto/test": "^3.2.0-rc.0"
38
38
  },
39
39
  "peerDependenciesMeta": {
40
40
  "@travetto/command": {
@@ -478,20 +478,23 @@ export abstract class SQLDialect implements DialectState {
478
478
  }
479
479
  break;
480
480
  }
481
- case '$empty': {
482
- const valueTable = this.parentTable(sStack);
483
- const alias = `_all_${sStack.length}`;
484
- const pPath = this.ident(this.parentPathField.name);
485
- const rpPath = this.resolveName([...sStack, field, this.parentPathField]);
486
-
487
- items.push(`0 ${v ? '=' : '<>'} (
488
- SELECT COUNT(${alias}.${this.ident(field.name)})
489
- FROM ${valueTable} ${alias}
490
- WHERE ${alias}.${pPath} = ${rpPath}
491
- )`);
481
+ case '$exists': {
482
+ if (field.array) {
483
+ const valueTable = this.parentTable(sStack);
484
+ const alias = `_all_${sStack.length}`;
485
+ const pPath = this.ident(this.parentPathField.name);
486
+ const rpPath = this.resolveName([...sStack, field, this.parentPathField]);
487
+
488
+ items.push(`0 ${!v ? '=' : '<>'} (
489
+ SELECT COUNT(${alias}.${this.ident(field.name)})
490
+ FROM ${valueTable} ${alias}
491
+ WHERE ${alias}.${pPath} = ${rpPath}
492
+ )`);
493
+ } else {
494
+ items.push(`${sPath} ${v ? SQL_OPS.$isNot : SQL_OPS.$is} NULL`);
495
+ }
492
496
  break;
493
497
  }
494
- case '$exists': items.push(`${sPath} ${v ? SQL_OPS.$isNot : SQL_OPS.$is} NULL`); break;
495
498
  case '$ne': case '$eq': {
496
499
  if (v === null || v === undefined) {
497
500
  items.push(`${sPath} ${subKey === '$ne' ? SQL_OPS.$isNot : SQL_OPS.$is} NULL`);