tortoise / tortoise/tortoise-orm

Support Field Comparison

Open
#1,325 4 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
5.6k
Forks
516
Avg merge
2d 21h
Merged PRs (30d)
9

Description

Is your feature request related to a problem? Please describe.
It can be the case (mine for instance), that one needs to compare two fields and filter those that do not match the comparison. Let's take as example the least active users, where we have two fields: registration_date and last_access. The great the gap, the least active (for the sake of the example, we assume that this metric is used for identifying users that aren't active).

Describe the solution you'd like
It would be handy to have a simple way to compare and filter row on the basis of the two fields. It could also be that the two fields belong to two different tables (related by a key or through other tables).

Describe alternatives you've considered
Using functions but it seems to not work.

Additional context
I've looked on the documentation and the issues back and forth, but with no luck. Hope this is not a duplicate (though that means the it is not visible enough on the docs).

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 by reviewing the filtering and functions documentation referenced in the issue, then inspect the existing field-filtering entry points. Clarify the intended comparison API and whether related-table fields are in scope; the work is done when mismatched rows can be filtered by comparing two fields, with coverage for the agreed cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
databases
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.