Fix adding a new revision to the store
This fixes a bug when attempting to add a revision to the store when the
version doesn't yet exist. This now proprly creates the new version
first.
@@ -96,6 +96,10 @@ impl<'a> PurchaseOrderStoreAddPurchaseOrderOperation
add_alternate_id::pg::add_alternate_id(self.conn, &id)?;
}
+ for version in versions {
+ add_purchase_order_version::pg::add_purchase_order_version(self.conn, &version)?;
+ }
+
for revision in revisions {
add_purchase_order_version_revision::pg::add_purchase_order_version_revision(
self.conn,
@@ -104,10 +108,6 @@ impl<'a> PurchaseOrderStoreAddPurchaseOrderOperation
)?;
}
- for version in versions {
- add_purchase_order_version::pg::add_purchase_order_version(self.conn, &version)?;
- }
-
let mut query = purchase_order::table.into_boxed().filter(
purchase_order::purchase_order_uid
.eq(&order.purchase_order_uid)
@@ -220,6 +220,12 @@ impl<'a> PurchaseOrderStoreAddPurchaseOrderOperation
add_alternate_id::sqlite::add_alternate_id(self.conn, &id)?;
}
+ for version in versions {
+ add_purchase_order_version::sqlite::add_purchase_order_version(
+ self.conn, &version,
+ )?;
+ }
+
for revision in revisions {
add_purchase_order_version_revision::sqlite::add_purchase_order_version_revision(
self.conn,
@@ -228,12 +234,6 @@ impl<'a> PurchaseOrderStoreAddPurchaseOrderOperation
)?;
}
- for version in versions {
- add_purchase_order_version::sqlite::add_purchase_order_version(
- self.conn, &version,
- )?;
- }
-
let mut query = purchase_order::table.into_boxed().filter(
purchase_order::purchase_order_uid
.eq(&order.purchase_order_uid)
