tortoise / tortoise/tortoise-orm
Custom lookup feature?
Open
Nobody has claimed this yet.
enhancement
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
I would like to request support for custom lookups in, similar to Django's implementation.
@fields.CharField.register_lookup
class MyCustomLookup(Lookup):
lookup_name = 'my_custom'
def as_sql(self, compiler, connection):
lhs, lhs_params = compiler.compile(self.lhs)
rhs, rhs_params = compiler.compile(self.rhs)
params = lhs_params + rhs_params
return '%s MY_OPERATOR %s' % (lhs, rhs), params
Model.filter(name__my_custom='test')
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 with the custom lookup registration example, including Lookup, as_sql, and Model.filter(name__my_custom='test'), then compare the referenced Django behavior with Tortoise ORM's query API. Done would require an agreed design for registration, SQL compilation, and lookup invocation; the issue names no repository files or tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100