From 94923d031cb60662a483efd671e426f1755ea246 Mon Sep 17 00:00:00 2001 From: tomg10 Date: Mon, 8 Jul 2024 16:57:07 +0200 Subject: [PATCH] fix query Signed-off-by: tomg10 --- ...b08a08c00b5cd8d725208b0ecfe8065c8f893ff38c49072a21fc.json} | 4 ++-- core/lib/dal/src/eth_sender_dal.rs | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) rename core/lib/dal/.sqlx/{query-aa92b31d0e0a2b353b66c501bf73b36b935046a9132f045ab105eaeac30c4a4d.json => query-6bb5eab89be2b08a08c00b5cd8d725208b0ecfe8065c8f893ff38c49072a21fc.json} (84%) diff --git a/core/lib/dal/.sqlx/query-aa92b31d0e0a2b353b66c501bf73b36b935046a9132f045ab105eaeac30c4a4d.json b/core/lib/dal/.sqlx/query-6bb5eab89be2b08a08c00b5cd8d725208b0ecfe8065c8f893ff38c49072a21fc.json similarity index 84% rename from core/lib/dal/.sqlx/query-aa92b31d0e0a2b353b66c501bf73b36b935046a9132f045ab105eaeac30c4a4d.json rename to core/lib/dal/.sqlx/query-6bb5eab89be2b08a08c00b5cd8d725208b0ecfe8065c8f893ff38c49072a21fc.json index b80a10462c07..71318c9a1023 100644 --- a/core/lib/dal/.sqlx/query-aa92b31d0e0a2b353b66c501bf73b36b935046a9132f045ab105eaeac30c4a4d.json +++ b/core/lib/dal/.sqlx/query-6bb5eab89be2b08a08c00b5cd8d725208b0ecfe8065c8f893ff38c49072a21fc.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "\n SELECT\n *\n FROM\n eth_txs\n WHERE\n from_addr IS NOT DISTINCT FROM $1 -- can't just use equality as NULL != NULL\n AND confirmed_eth_tx_history_id IS NULL\n AND id <= (\n SELECT\n COALESCE(MAX(eth_tx_id), 0)\n FROM\n eth_txs_history\n WHERE\n sent_at_block IS NOT NULL\n )\n ORDER BY\n id\n ", + "query": "\n SELECT\n *\n FROM\n eth_txs\n WHERE\n from_addr IS NOT DISTINCT FROM $1 -- can't just use equality as NULL != NULL\n AND confirmed_eth_tx_history_id IS NULL\n AND id <= (\n SELECT\n COALESCE(MAX(eth_tx_id), 0)\n FROM\n eth_txs_history\n JOIN eth_txs ON eth_txs.id = eth_txs_history.eth_tx_id\n WHERE\n eth_txs_history.sent_at_block IS NOT NULL\n AND eth_txs.from_addr IS NOT DISTINCT FROM $1\n )\n ORDER BY\n id\n ", "describe": { "columns": [ { @@ -96,5 +96,5 @@ true ] }, - "hash": "aa92b31d0e0a2b353b66c501bf73b36b935046a9132f045ab105eaeac30c4a4d" + "hash": "6bb5eab89be2b08a08c00b5cd8d725208b0ecfe8065c8f893ff38c49072a21fc" } diff --git a/core/lib/dal/src/eth_sender_dal.rs b/core/lib/dal/src/eth_sender_dal.rs index bb27cf8c1f68..e05839281e09 100644 --- a/core/lib/dal/src/eth_sender_dal.rs +++ b/core/lib/dal/src/eth_sender_dal.rs @@ -41,8 +41,10 @@ impl EthSenderDal<'_, '_> { COALESCE(MAX(eth_tx_id), 0) FROM eth_txs_history + JOIN eth_txs ON eth_txs.id = eth_txs_history.eth_tx_id WHERE - sent_at_block IS NOT NULL + eth_txs_history.sent_at_block IS NOT NULL + AND eth_txs.from_addr IS NOT DISTINCT FROM $1 ) ORDER BY id