From 2ff420a09736e723dd9ea122d70f527962a1e224 Mon Sep 17 00:00:00 2001 From: Tim Mecklem Date: Wed, 30 May 2018 21:37:35 -0400 Subject: [PATCH] Move internal transaction type comparison out of fragment Co-authored-by: Igor Florian --- apps/explorer/lib/explorer/chain.ex | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index f5524e45e6..915288d48e 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1855,15 +1855,18 @@ defmodule Explorer.Chain do end defp where_transaction_has_multiple_internal_transactions(query) do - query - |> where( - [it, transaction], - fragment( - "(? != ? OR (SELECT COUNT(sibling.id) FROM internal_transactions as sibling WHERE sibling.transaction_hash = ?) > 1)", - it.type, - "call", - transaction.hash - ) + where( + query, + [internal_transaction, transaction], + internal_transaction.type != ^:call or + fragment( + """ + (SELECT COUNT(sibling.id) + FROM internal_transactions AS sibling + WHERE sibling.transaction_hash = ?) + """, + transaction.hash + ) > 1 ) end end