fix: quote string parameters in prepareQuery to prevent PostgreSQL type errors#10
Open
fix: quote string parameters in prepareQuery to prevent PostgreSQL type errors#10
Conversation
696b4bd to
82031c0
Compare
Hex strings (0x...) should remain unquoted so sqlparser treats them as HexStringLiteral, which the Index Supply backend converts to proper PostgreSQL bytea format (\x...). Other string parameters are quoted to be treated as text literals. This fixes 'bytea = bit' type mismatch errors when querying with many hex address/hash parameters.
82031c0 to
d5f4103
Compare
gakonst
added a commit
to tempoxyz/tempo-apps
that referenced
this pull request
Jan 15, 2026
Fixes explorer activity not showing due to 'bytea = bit' PostgreSQL type mismatch when querying with hex strings in WHERE IN clauses. See: wevm/idxs#10
gakonst
added a commit
to tempoxyz/tempo-apps
that referenced
this pull request
Jan 15, 2026
Fixes explorer activity not showing due to 'bytea = bit' PostgreSQL type mismatch when querying with hex strings in WHERE IN clauses. See: wevm/idxs#10
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
String parameters like hex addresses (
0xabc...) were being inserted into SQL queries without quotes viaString(param), causing PostgreSQL to interpret them as bit literals instead of text values.This resulted in
bytea = bittype mismatch errors when queries had many OR conditions (e.g., >18 parameters).Reproduction
Root Cause
In
prepareQuery(), line 373:This converts
0xabc123...without SQL quoting, so PostgreSQL sees an unquoted0x...which it interprets as a bit literal.Solution
$10is replaced before$1(prevents partial replacements like$1matching inside$10)Testing
Verified fix resolves the issue in tempo-apps explorer with queries containing 20+ hash parameters.