Skip to content

Commit

Permalink
fix shares column receiving wrong name and type
Browse files Browse the repository at this point in the history
when using an agg function like sum(), if a name is not provided, the
column will be called 'sum'.

I'm not sure why, the type of the summed column with a numeric column,
which is incompatible with an int8 field that maps to a i64 in rust.
  • Loading branch information
michaeldjeffrey committed Sep 10, 2024
1 parent f12954c commit 5af0374
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions mobile_verifier/src/promotion_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -322,12 +322,12 @@ impl AggregatePromotionRewards {
) -> anyhow::Result<Self> {
let rewards = sqlx::query_as(
r#"
SELECT subscriber_id, NULL as gateway_key, SUM(shares), carrier_key
SELECT subscriber_id, NULL as gateway_key, SUM(shares)::bigint as shares, carrier_key
FROM subscriber_promotion_rewards
WHERE time_of_reward >= $1 AND time_of_reward < $2
GROUP BY subscriber_id, carrier_key
UNION
SELECT NULL as subscriber_id, gateway_key, SUM(shares), carrier_key
SELECT NULL as subscriber_id, gateway_key, SUM(shares)::bigint as shares, carrier_key
FROM gateway_promotion_rewards
WHERE time_of_reward >= $1 AND time_of_reward < $2
GROUP BY gateway_key, carrier_key
Expand All @@ -349,6 +349,7 @@ impl AggregatePromotionRewards {
})
.try_collect()
.await?;

Ok(Self { rewards })
}

Expand Down

0 comments on commit 5af0374

Please sign in to comment.