Skip to content

Commit

Permalink
perf(core): Correctly optimized OrderItem persistence
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelbromley committed Feb 16, 2021
1 parent 42bf55a commit 5c879e7
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 3 deletions.
2 changes: 0 additions & 2 deletions packages/core/e2e/order-taxes.e2e-spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/* tslint:disable:no-non-null-assertion */
import { summate } from '@vendure/common/lib/shared-utils';
import { createErrorResultGuard, createTestEnvironment, ErrorResultGuard } from '@vendure/testing';
import gql from 'graphql-tag';
import path from 'path';

import { initialData } from '../../../e2e-common/e2e-initial-data';
Expand All @@ -11,7 +10,6 @@ import { testSuccessfulPaymentMethod } from './fixtures/test-payment-methods';
import { GetProductsWithVariantPrices, UpdateChannel } from './graphql/generated-e2e-admin-types';
import {
AddItemToOrder,
AdjustmentType,
GetActiveOrderWithPriceData,
TestOrderFragmentFragment,
UpdatedOrderFragment,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,9 @@ export class OrderModifier {
.values(newOrderItems)
.execute();
newOrderItems.forEach((item, i) => (item.id = identifiers[i].id));
orderLine.items.push(...newOrderItems);
orderLine.items = await this.connection
.getRepository(ctx, OrderItem)
.find({ where: { line: orderLine } });
} else if (quantity < currentQuantity) {
if (order.active) {
// When an Order is still active, it is fine to just delete
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/service/services/order.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1339,6 +1339,7 @@ export class OrderService {
.getRepository(ctx, OrderItem)
.createQueryBuilder()
.insert()
.into(OrderItem, [...updateFields, 'id', 'lineId'])
.values(updatedItems)
.orUpdate({
conflict_target: ['id'],
Expand Down

0 comments on commit 5c879e7

Please sign in to comment.