pallets-eco / pallets-eco/flask-admin

sqla search does not support columns with distinct attribute names

Open
#1,973 1 comment 0 reactions 0 assignees View on GitHub

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

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.