@nocobase/database 1.5.0-alpha.5 → 1.6.0-alpha.1

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.
@@ -258,7 +258,11 @@ async function updateSingleAssociation(model, key, value, options = {}) {
258
258
  return;
259
259
  }
260
260
  if (updateAssociationValues.includes(key)) {
261
- await instance2.update(value, { ...options, transaction });
261
+ const updateValues = { ...value };
262
+ if (association.associationType === "HasOne") {
263
+ delete updateValues[association.foreignKey];
264
+ }
265
+ await instance2.update(updateValues, { ...options, transaction });
262
266
  }
263
267
  await updateAssociations(instance2, value, {
264
268
  ...options,
@@ -298,7 +302,7 @@ async function updateMultipleAssociation(model, key, value, options = {}) {
298
302
  const setAccessor = association.accessors.set;
299
303
  const createAccessor = association.accessors.create;
300
304
  if (isUndefinedOrNull(value)) {
301
- await model[setAccessor](null, { transaction, context, individualHooks: true });
305
+ await model[setAccessor](null, { transaction, context, individualHooks: true, validate: false });
302
306
  model.setDataValue(key, null);
303
307
  return;
304
308
  }
@@ -306,7 +310,7 @@ async function updateMultipleAssociation(model, key, value, options = {}) {
306
310
  throw new Error(`The source key ${association.sourceKeyAttribute} is not set in ${model.constructor.name}`);
307
311
  }
308
312
  if (isStringOrNumber(value)) {
309
- await model[setAccessor](value, { transaction, context, individualHooks: true });
313
+ await model[setAccessor](value, { transaction, context, individualHooks: true, validate: false });
310
314
  return;
311
315
  }
312
316
  value = import_lodash.default.castArray(value);
@@ -334,7 +338,7 @@ async function updateMultipleAssociation(model, key, value, options = {}) {
334
338
  objectItems.push(item);
335
339
  }
336
340
  }
337
- await model[setAccessor](setItems, { transaction, context, individualHooks: true });
341
+ await model[setAccessor](setItems, { transaction, context, individualHooks: true, validate: false });
338
342
  const newItems = [];
339
343
  const pk = association.target.primaryKeyAttribute;
340
344
  let targetKey = pk;
@@ -393,6 +397,9 @@ async function updateMultipleAssociation(model, key, value, options = {}) {
393
397
  continue;
394
398
  }
395
399
  if (updateAssociationValues.includes(key)) {
400
+ if (association.associationType === "HasMany") {
401
+ delete item[association.foreignKey];
402
+ }
396
403
  await instance.update(item, { ...options, transaction });
397
404
  }
398
405
  await updateAssociations(instance, item, {
@@ -62,7 +62,7 @@ const _ViewFieldInference = class _ViewFieldInference {
62
62
  });
63
63
  const rawFields = [];
64
64
  for (const [name, column] of Object.entries(columns)) {
65
- const inferResult = { name, rawType: column.type };
65
+ const inferResult = { name, rawType: column.type, field: name };
66
66
  const usage = columnUsage[name];
67
67
  if (usage) {
68
68
  const collection = db.tableNameCollectionMap.get(
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@nocobase/database",
3
- "version": "1.5.0-alpha.5",
3
+ "version": "1.6.0-alpha.1",
4
4
  "description": "",
5
5
  "main": "./lib/index.js",
6
6
  "types": "./lib/index.d.ts",
7
7
  "license": "AGPL-3.0",
8
8
  "dependencies": {
9
- "@nocobase/logger": "1.5.0-alpha.5",
10
- "@nocobase/utils": "1.5.0-alpha.5",
9
+ "@nocobase/logger": "1.6.0-alpha.1",
10
+ "@nocobase/utils": "1.6.0-alpha.1",
11
11
  "async-mutex": "^0.3.2",
12
12
  "chalk": "^4.1.1",
13
13
  "cron-parser": "4.4.0",
@@ -38,5 +38,5 @@
38
38
  "url": "git+https://github.com/nocobase/nocobase.git",
39
39
  "directory": "packages/database"
40
40
  },
41
- "gitHead": "8d24e8d2c0f3f57ceaa271438fd93db2b4150011"
41
+ "gitHead": "a4c91015e34ec0c9a427451b5fbdfb5fedc4f3d7"
42
42
  }