@nocobase/plugin-collection-sql 2.3.0-beta.7 → 2.3.0-beta.9

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.
@@ -8,20 +8,20 @@
8
8
  */
9
9
 
10
10
  module.exports = {
11
- "@nocobase/client": "2.3.0-beta.7",
11
+ "@nocobase/client": "2.3.0-beta.9",
12
12
  "@ant-design/icons": "5.6.1",
13
- "@nocobase/client-v2": "2.3.0-beta.7",
14
- "@nocobase/flow-engine": "2.3.0-beta.7",
15
- "@nocobase/plugin-data-source-manager": "2.3.0-beta.7",
13
+ "@nocobase/client-v2": "2.3.0-beta.9",
14
+ "@nocobase/flow-engine": "2.3.0-beta.9",
15
+ "@nocobase/plugin-data-source-manager": "2.3.0-beta.9",
16
16
  "ahooks": "3.7.8",
17
17
  "antd": "5.24.2",
18
18
  "dayjs": "1.11.13",
19
19
  "lodash": "4.18.1",
20
20
  "react": "18.2.0",
21
- "@nocobase/data-source-manager": "2.3.0-beta.7",
22
- "@nocobase/database": "2.3.0-beta.7",
23
- "@nocobase/server": "2.3.0-beta.7",
24
- "@nocobase/actions": "2.3.0-beta.7",
21
+ "@nocobase/data-source-manager": "2.3.0-beta.9",
22
+ "@nocobase/database": "2.3.0-beta.9",
23
+ "@nocobase/server": "2.3.0-beta.9",
24
+ "@nocobase/actions": "2.3.0-beta.9",
25
25
  "sequelize": "6.35.2",
26
- "@nocobase/utils": "2.3.0-beta.7"
26
+ "@nocobase/utils": "2.3.0-beta.9"
27
27
  };
@@ -73,7 +73,8 @@ class SQLCollection extends import_database.Collection {
73
73
  if (!autoGenId) {
74
74
  model.removeAttribute("id");
75
75
  }
76
- model.sql = (sql == null ? void 0 : sql.endsWith(";")) ? sql.slice(0, -1) : sql;
76
+ const normalizedSQL = sql == null ? void 0 : sql.trim();
77
+ model.sql = (normalizedSQL == null ? void 0 : normalizedSQL.endsWith(";")) ? normalizedSQL.slice(0, -1) : normalizedSQL;
77
78
  model.database = this.context.database;
78
79
  model.collection = this;
79
80
  this.model = new Proxy(model, {
@@ -32,24 +32,10 @@ module.exports = __toCommonJS(utils_exports);
32
32
  const checkSQL = (sql) => {
33
33
  const dangerKeywords = [
34
34
  // PostgreSQL
35
- "pg_read_file",
36
- "pg_read_binary_file",
37
- "pg_stat_file",
38
- "pg_ls_dir",
39
- "pg_logdir_ls",
40
- "pg_terminate_backend",
41
- "pg_cancel_backend",
35
+ "pg_",
42
36
  "current_setting",
43
37
  "set_config",
44
- "pg_reload_conf",
45
- "pg_sleep",
46
38
  "generate_series",
47
- "pg_catalog",
48
- "pg_shadow",
49
- "pg_authid",
50
- "pg_auth_members",
51
- "pg_roles",
52
- "pg_stat_activity",
53
39
  "information_schema",
54
40
  // MySQL
55
41
  "LOAD_FILE",
@@ -60,7 +46,13 @@ const checkSQL = (sql) => {
60
46
  "sqlite3_load_extension",
61
47
  "load_extension"
62
48
  ];
63
- sql = sql.trim().split(";").shift() || "";
49
+ sql = sql.trim();
50
+ if (sql.endsWith(";")) {
51
+ sql = sql.slice(0, -1);
52
+ }
53
+ if (sql.includes(";")) {
54
+ throw new Error("Only supports SELECT statements or WITH clauses");
55
+ }
64
56
  if (!/^select/i.test(sql) && !/^with([\s\S]+)select([\s\S]+)/i.test(sql)) {
65
57
  throw new Error("Only supports SELECT statements or WITH clauses");
66
58
  }
package/package.json CHANGED
@@ -6,7 +6,7 @@
6
6
  "description": "Provides SQL collection template",
7
7
  "description.ru-RU": "Предоставляет шаблон коллекции на основе SQL",
8
8
  "description.zh-CN": "提供 SQL 数据表模板",
9
- "version": "2.3.0-beta.7",
9
+ "version": "2.3.0-beta.9",
10
10
  "homepage": "https://docs-cn.nocobase.com/handbook/collection-sql",
11
11
  "homepage.ru-RU": "https://docs-ru.nocobase.com/handbook/collection-sql",
12
12
  "homepage.zh-CN": "https://docs-cn.nocobase.com/handbook/collection-sql",
@@ -23,5 +23,5 @@
23
23
  "keywords": [
24
24
  "Collections"
25
25
  ],
26
- "gitHead": "3485d95ce53290d6e74d68222a0568ea60420e23"
26
+ "gitHead": "c215e60ed704afe6c086bd96304f4b0d3b46d02e"
27
27
  }