@nocobase/plugin-field-sort 2.1.0-beta.12 → 2.1.0-beta.14

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.
@@ -10,13 +10,13 @@
10
10
  module.exports = {
11
11
  "antd": "5.24.2",
12
12
  "react": "18.2.0",
13
- "@nocobase/flow-engine": "2.1.0-beta.12",
14
- "@nocobase/client": "2.1.0-beta.12",
15
- "lodash": "4.17.21",
16
- "@nocobase/database": "2.1.0-beta.12",
17
- "@nocobase/actions": "2.1.0-beta.12",
18
- "@nocobase/server": "2.1.0-beta.12",
19
- "@nocobase/data-source-manager": "2.1.0-beta.12",
13
+ "@nocobase/flow-engine": "2.1.0-beta.14",
14
+ "@nocobase/client": "2.1.0-beta.14",
15
+ "lodash": "4.18.1",
16
+ "@nocobase/database": "2.1.0-beta.14",
17
+ "@nocobase/actions": "2.1.0-beta.14",
18
+ "@nocobase/server": "2.1.0-beta.14",
19
+ "@nocobase/data-source-manager": "2.1.0-beta.14",
20
20
  "sequelize": "6.35.2",
21
- "@nocobase/lock-manager": "2.1.0-beta.12"
21
+ "@nocobase/lock-manager": "2.1.0-beta.14"
22
22
  };
@@ -117,15 +117,23 @@ class SortField extends import_database.Field {
117
117
  const quotedOrderField = queryInterface.quoteIdentifier(orderField);
118
118
  const sortColumnName = queryInterface.quoteIdentifier(this.collection.model.rawAttributes[this.name].field);
119
119
  let sql;
120
+ let bind;
120
121
  const whereClause = scopeKey2 && scopeValue ? (() => {
121
122
  const filteredScopeValue = scopeValue.filter((v) => v !== null);
122
- if (filteredScopeValue.length === 0) {
123
+ const clauses = [];
124
+ if (filteredScopeValue.length > 0) {
125
+ bind = filteredScopeValue;
126
+ const placeholders = filteredScopeValue.map((_, index) => `$${index + 1}`).join(", ");
127
+ clauses.push(`${queryInterface.quoteIdentifier(scopeKey2)} IN (${placeholders})`);
128
+ }
129
+ if (scopeValue.includes(null)) {
130
+ clauses.push(`${queryInterface.quoteIdentifier(scopeKey2)} IS NULL`);
131
+ }
132
+ if (clauses.length === 0) {
123
133
  return "";
124
134
  }
125
- const initialClause = `
126
- WHERE ${queryInterface.quoteIdentifier(scopeKey2)} IN (${filteredScopeValue.map((v) => `'${v}'`).join(", ")})`;
127
- const nullCheck = scopeValue.includes(null) ? ` OR ${queryInterface.quoteIdentifier(scopeKey2)} IS NULL` : "";
128
- return initialClause + nullCheck;
135
+ return `
136
+ WHERE ${clauses.join(" OR ")}`;
129
137
  })() : "";
130
138
  if (this.collection.db.inDialect("postgres")) {
131
139
  sql = `
@@ -163,6 +171,7 @@ class SortField extends import_database.Field {
163
171
  `;
164
172
  }
165
173
  await this.collection.db.sequelize.query(sql, {
174
+ bind,
166
175
  transaction
167
176
  });
168
177
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nocobase/plugin-field-sort",
3
- "version": "2.1.0-beta.12",
3
+ "version": "2.1.0-beta.14",
4
4
  "license": "Apache-2.0",
5
5
  "displayName": "Collection field: Sort",
6
6
  "displayName.ru-RU": "Поле коллекции: Сортировка",
@@ -16,11 +16,11 @@
16
16
  "@nocobase/lock-manager": "2.x",
17
17
  "@nocobase/server": "2.x",
18
18
  "@nocobase/test": "2.x",
19
- "lodash": "4.17.21",
19
+ "lodash": "4.x",
20
20
  "sequelize": "^6.26.0"
21
21
  },
22
22
  "keywords": [
23
23
  "Collection fields"
24
24
  ],
25
- "gitHead": "25cee9643f42f850afc4adc33c55a56850ac730d"
25
+ "gitHead": "cd55c9a14596d834c30c83a82c38f1f719f7aac4"
26
26
  }