@strapi/database 4.11.4 → 4.12.0-beta.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.
@@ -33,6 +33,10 @@ class Dialect {
33
33
  return true;
34
34
  }
35
35
 
36
+ supportsOperator() {
37
+ return true;
38
+ }
39
+
36
40
  async startSchemaUpdate() {
37
41
  // noop
38
42
  }
@@ -7,6 +7,8 @@ const errors = require('../../errors');
7
7
  const { Dialect } = require('../dialect');
8
8
  const SqliteSchemaInspector = require('./schema-inspector');
9
9
 
10
+ const UNSUPPORTED_OPERATORS = ['$jsonSupersetOf'];
11
+
10
12
  class SqliteDialect extends Dialect {
11
13
  constructor(db) {
12
14
  super(db);
@@ -54,6 +56,10 @@ class SqliteDialect extends Dialect {
54
56
  }
55
57
  }
56
58
 
59
+ supportsOperator(operator) {
60
+ return !UNSUPPORTED_OPERATORS.includes(operator);
61
+ }
62
+
57
63
  async startSchemaUpdate() {
58
64
  await this.db.connection.raw(`pragma foreign_keys = off`);
59
65
  }
@@ -276,7 +276,14 @@ const applyOperator = (qb, column, operator, value) => {
276
276
  break;
277
277
  }
278
278
 
279
- // TODO: json operators
279
+ // Only on MySQL, PostgreSQL and CockroachDB.
280
+ // https://knexjs.org/guide/query-builder.html#wherejsonsupersetof
281
+ case '$jsonSupersetOf': {
282
+ qb.whereJsonSupersetOf(column, value);
283
+ break;
284
+ }
285
+
286
+ // TODO: Add more JSON operators: whereJsonObject, whereJsonPath, whereJsonSubsetOf
280
287
 
281
288
  // TODO: relational operators every/some/exists/size ...
282
289
 
@@ -370,7 +370,9 @@ module.exports = (db) => {
370
370
  })
371
371
  .map((dependsOnTable) => {
372
372
  return srcSchema.tables.find((srcTable) => srcTable.name === dependsOnTable.name);
373
- });
373
+ })
374
+ // In case the table is not found, filter undefined values
375
+ .filter((table) => !_.isNil(table));
374
376
 
375
377
  removedTables.push(srcTable, ...dependencies);
376
378
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strapi/database",
3
- "version": "4.11.4",
3
+ "version": "4.12.0-beta.0",
4
4
  "description": "Strapi's database layer",
5
5
  "homepage": "https://strapi.io",
6
6
  "bugs": {
@@ -33,7 +33,7 @@
33
33
  "lint": "run -T eslint ."
34
34
  },
35
35
  "dependencies": {
36
- "@strapi/utils": "4.11.4",
36
+ "@strapi/utils": "4.12.0-beta.0",
37
37
  "date-fns": "2.30.0",
38
38
  "debug": "4.3.4",
39
39
  "fs-extra": "10.0.0",
@@ -46,5 +46,5 @@
46
46
  "node": ">=14.19.1 <=18.x.x",
47
47
  "npm": ">=6.0.0"
48
48
  },
49
- "gitHead": "8d325a695386ab9b578b360bf768cfa25173050f"
49
+ "gitHead": "b965b428a445bdbc81fb4b70120237f2d48e7647"
50
50
  }