Commit e2bfb73
authored
fix(api): /contracts/recent ORDER BY shadowed by text-cast alias (#43)
SELECT first_seen_block::text creates an output column with the same
name as the base column but type text. Postgres' ORDER BY resolves
unqualified names to the SELECT-list output FIRST, so the rows came
back sorted by text-lex ("881639" > "2575000") instead of bigint.
Symptom: rank 1 = 0xc9d7a61d (block 881639) ahead of rank 2 = 0x21a24d63
(block 2575000), even though the SQL says DESC. This bit
ethereum-lists/chains#8266 — Marco's contract showed at rank 2 with a
canonical SentrixSafe deploy at rank 1 due to lex ordering.
Fix: qualify ORDER BY ${addresses}.first_seen_block so the planner
references the base column, not the text-cast alias. /whale/tx and
others already do this via `t.value` style table prefixes.
Co-authored-by: satyakwok <satyakwok@users.noreply.github.com>1 parent 0ab6290 commit e2bfb73
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
307 | | - | |
| 307 | + | |
308 | 308 | | |
309 | 309 | | |
310 | 310 | | |
| |||
0 commit comments