vona-module-a-orm 5.0.44 → 5.0.45

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.
Files changed (2) hide show
  1. package/dist/index.js +16 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1948,6 +1948,9 @@ class BeanModelCrudInner extends BeanModelView {
1948
1948
  const dataTemp2 = this._prepareInsertDataByOptions(table, dataTemp, options);
1949
1949
  // then
1950
1950
  const [dataNew, dataNewOriginal] = await this.prepareData(table, dataTemp2);
1951
+ if (isNil(cast(dataNewOriginal).id) && Object.prototype.hasOwnProperty.call(dataNewOriginal, 'id')) {
1952
+ delete cast(dataNewOriginal).id;
1953
+ }
1951
1954
  datas.push(dataNew);
1952
1955
  datasOriginal.push(dataNewOriginal);
1953
1956
  }
@@ -2494,7 +2497,7 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
2494
2497
  for (let index = 0; index < entities.length; index++) {
2495
2498
  const entity = entities[index];
2496
2499
  if (entity[relationName]) {
2497
- // donot checkif has id of entity[relationName], for safety
2500
+ // donot check if has id of entity[relationName], for safety
2498
2501
  const item = await modelTarget.get({
2499
2502
  [key]: cast(entity).id
2500
2503
  });
@@ -2527,13 +2530,18 @@ let ServiceRelations = (_dec$a = Service(), _dec2$a = BeanInfo({
2527
2530
  if (entity[relationName] && entity[relationName].length > 0) {
2528
2531
  const entityId = cast(entity).id;
2529
2532
  const idsTo = entity[relationName].map(item => item.id).filter(id => !isNil(id));
2530
- const itemsTarget = await cast(modelTarget).__select_raw(undefined, {
2531
- where: {
2532
- [key]: entityId,
2533
- id: idsTo
2534
- }
2535
- }, methodOptionsReal);
2536
- const idsTarget = itemsTarget.map(item => item.id);
2533
+ let idsTarget;
2534
+ if (idsTo.length === 0) {
2535
+ idsTarget = [];
2536
+ } else {
2537
+ const itemsTarget = await cast(modelTarget).__select_raw(undefined, {
2538
+ where: {
2539
+ [key]: entityId,
2540
+ id: idsTo
2541
+ }
2542
+ }, methodOptionsReal);
2543
+ idsTarget = itemsTarget.map(item => item.id);
2544
+ }
2537
2545
  for (const child of entity[relationName]) {
2538
2546
  if (!isNil(child.id) && !idsTarget.includes(child.id)) {
2539
2547
  throw new Error(`invalid id: ${child.id}`);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "vona-module-a-orm",
3
3
  "type": "module",
4
- "version": "5.0.44",
4
+ "version": "5.0.45",
5
5
  "title": "a-orm",
6
6
  "vonaModule": {
7
7
  "capabilities": {