Fix revision count in `po version show`
Adds filter to select only revisions of the same purchase order
when showing a po version. Previously, if versions of different
purchase orders had the same version ID, the revision count would
include all revisions of versions with that name.
@@ -84,8 +84,12 @@ impl<'a> PurchaseOrderStoreGetPurchaseOrderVersionOperation
.into_boxed()
.select(purchase_order_version_revision::all_columns)
.filter(
+ purchase_order_version_revision::purchase_order_uid
+ .eq(&purchase_order_uid)
+ .and(
purchase_order_version_revision::version_id
- .eq(&version_id)
+ .eq(&version.version_id),
+ )
.and(
purchase_order_version_revision::end_commit_num
.eq(MAX_COMMIT_NUM),
@@ -168,8 +172,12 @@ impl<'a> PurchaseOrderStoreGetPurchaseOrderVersionOperation
.into_boxed()
.select(purchase_order_version_revision::all_columns)
.filter(
+ purchase_order_version_revision::purchase_order_uid
+ .eq(&purchase_order_uid)
+ .and(
purchase_order_version_revision::version_id
- .eq(&version_id)
+ .eq(&version.version_id),
+ )
.and(
purchase_order_version_revision::end_commit_num
.eq(MAX_COMMIT_NUM),
