Skip to content

Commit

Permalink
Fix query for getting txs for address (#2272)
Browse files Browse the repository at this point in the history
Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo committed Jul 29, 2022
1 parent f3740c5 commit 54be63f
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions core/lib/storage/src/chain/operations_ext/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1188,7 +1188,7 @@ impl<'a, 'c> OperationsExtSchema<'a, 'c> {
};

let token_query = if token.is_some() {
"AND a.token = $2"
"AND token = $2"
} else {
""
};
Expand All @@ -1208,7 +1208,9 @@ impl<'a, 'c> OperationsExtSchema<'a, 'c> {
b.block_index,
Null::bigint as batch_id
FROM executed_priority_operations as b
WHERE EXISTS ( SELECT 1 FROM tx_filters as a WHERE a.tx_hash = b.tx_hash AND a.address = $1 {} )
JOIN
(SELECT DISTINCT tx_hash FROM tx_filters WHERE address = $1 {})
as a ON a.tx_hash = b.tx_hash
{}
"#,
token_query, query_direction
Expand Down Expand Up @@ -1244,7 +1246,7 @@ impl<'a, 'c> OperationsExtSchema<'a, 'c> {
};

let token_query = if token.is_some() {
"AND a.token = $2"
"AND token = $2"
} else {
""
};
Expand All @@ -1264,7 +1266,9 @@ impl<'a, 'c> OperationsExtSchema<'a, 'c> {
txs.block_index,
txs.batch_id
FROM executed_transactions as txs
WHERE EXISTS ( SELECT 1 FROM tx_filters as a WHERE a.tx_hash = txs.tx_hash AND a.address = $1 {} )
JOIN
(SELECT DISTINCT tx_hash FROM tx_filters WHERE address = $1 {})
as a ON a.tx_hash = txs.tx_hash
{}
"#,
token_query, query_direction
Expand Down

0 comments on commit 54be63f

Please sign in to comment.