forest-express-sequelize 9.0.0-beta.2 → 9.0.0-beta.4

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/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ # [9.0.0-beta.4](https://github.com/ForestAdmin/forest-express-sequelize/compare/v9.0.0-beta.3...v9.0.0-beta.4) (2022-11-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **chart:** add support for context variables inside SQL query ([#1028](https://github.com/ForestAdmin/forest-express-sequelize/issues/1028)) ([6bf678e](https://github.com/ForestAdmin/forest-express-sequelize/commit/6bf678ead766a202908c0bf8f5376e9c45d9ef6f))
7
+
8
+ # [9.0.0-beta.3](https://github.com/ForestAdmin/forest-express-sequelize/compare/v9.0.0-beta.2...v9.0.0-beta.3) (2022-11-02)
9
+
10
+
11
+ ### Features
12
+
13
+ * **chart:** add support for context variables used by Workspaces ([#1029](https://github.com/ForestAdmin/forest-express-sequelize/issues/1029)) ([dc3009a](https://github.com/ForestAdmin/forest-express-sequelize/commit/dc3009acf395292cf28a8d7b481d36f78bb9d829))
14
+
1
15
  # [9.0.0-beta.2](https://github.com/ForestAdmin/forest-express-sequelize/compare/v9.0.0-beta.1...v9.0.0-beta.2) (2022-10-28)
2
16
 
3
17
 
@@ -6,23 +6,21 @@ require("core-js/modules/es.regexp.exec.js");
6
6
 
7
7
  require("core-js/modules/es.string.replace.js");
8
8
 
9
- require("core-js/modules/es.regexp.constructor.js");
10
-
11
9
  function QueryStatGetter(params, opts) {
12
- const QUERY_OPTIONS_SELECT = {
13
- type: opts.Sequelize.QueryTypes.SELECT
14
- };
15
-
16
10
  this.perform = function perform() {
17
11
  let rawQuery = params.query.trim();
12
+ const bind = params.contextVariables || {};
18
13
 
19
- if (params.record_id) {
20
- rawQuery = rawQuery.replace(new RegExp('\\?', 'g'), params.record_id);
14
+ if (bind.recordId && !rawQuery.includes('$recordId')) {
15
+ rawQuery = rawQuery.replace(/\?/g, '$recordId');
21
16
  } // WARNING: Choosing the first connection might generate issues if the model
22
17
  // does not belongs to this database.
23
18
 
24
19
 
25
- return Object.values(opts.connections)[0].query(rawQuery, QUERY_OPTIONS_SELECT);
20
+ return Object.values(opts.connections)[0].query(rawQuery, {
21
+ type: opts.Sequelize.QueryTypes.SELECT,
22
+ bind
23
+ });
26
24
  };
27
25
  }
28
26
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "forest-express-sequelize",
3
3
  "description": "Official Express/Sequelize Liana for Forest",
4
- "version": "9.0.0-beta.2",
4
+ "version": "9.0.0-beta.4",
5
5
  "author": "Sandro Munda <sandro@munda.me>",
6
6
  "contributors": [
7
7
  "Arnaud Besnier <arnaudibesnier@gmail.com>",
@@ -28,7 +28,7 @@
28
28
  "@babel/runtime": "7.15.4",
29
29
  "bluebird": "2.9.25",
30
30
  "core-js": "3.6.5",
31
- "forest-express": "10.0.0-beta.2",
31
+ "forest-express": "10.0.0",
32
32
  "http-errors": "1.6.1",
33
33
  "lodash": "4.17.21",
34
34
  "moment": "2.29.4",