-
Notifications
You must be signed in to change notification settings - Fork 21
Fix: use ILIKE instead of == for address comparison.
#887
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -91,7 +91,7 @@ def get_total_detailed_balance( | |
| query = ( | ||
| select(func.sum(AlephBalanceDb.balance)) | ||
| .where( | ||
| (AlephBalanceDb.address == address) | ||
| AlephBalanceDb.address.ilike(address) | ||
|
||
| & (AlephBalanceDb.chain == chain) | ||
| & ((AlephBalanceDb.dapp.is_(None)) if not include_dapps else True) | ||
| ) | ||
|
|
@@ -104,7 +104,7 @@ def get_total_detailed_balance( | |
| query = ( | ||
| select(AlephBalanceDb.chain, func.sum(AlephBalanceDb.balance).label("balance")) | ||
| .where( | ||
| (AlephBalanceDb.address == address) | ||
| AlephBalanceDb.address.ilike(address) | ||
|
||
| & ((AlephBalanceDb.dapp.is_(None)) if not include_dapps else True) | ||
| ) | ||
| .group_by(AlephBalanceDb.chain) | ||
|
|
@@ -118,7 +118,7 @@ def get_total_detailed_balance( | |
| query = ( | ||
| select(func.sum(AlephBalanceDb.balance)) | ||
| .where( | ||
| (AlephBalanceDb.address == address) | ||
| AlephBalanceDb.address.ilike(address) | ||
|
||
| & ((AlephBalanceDb.dapp.is_(None)) if not include_dapps else True) | ||
| ) | ||
| .group_by(AlephBalanceDb.address) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using
ilikefor address comparison is problematic because it's a SQL pattern matching operator that treats%and_as wildcards. If an address contains these characters, they will be interpreted as wildcards rather than literal characters, potentially matching multiple addresses incorrectly.For case-insensitive exact matching, consider using
func.lower()on both sides of the comparison instead:This approach: