pallets-eco / pallets-eco/flask-admin
sqla search does not support columns with distinct attribute names
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 6.1k
- Forks
- 1.6k
- Avg merge
- 6d 14h
- Merged PRs (30d)
- 1
Description
Hi,
I have a model where i had to use attribute names distinct from column names
id_ = db.Column('id', ...
This is not supported by the search because _apply_search uses getattr to find
the column in case of aliased model, but the field.key is taken from the column name:
column = field if alias is None else getattr(alias, field.key)
any suggestions how to fix this?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in apply_search and inspect how aliased models resolve fields when a SQLAlchemy column has a different attribute name, such as id mapped to id. Reproduce the search with that model and verify that aliased searches locate the mapped attribute and return the expected results.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, sqlalchemy
- Domain
- backend, database
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100