luckyframework / luckyframework/avram
Add named scope inversion with "not"
Nobody has claimed this yet.
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
I'm wanting to write a named scope like this:
```cr
class TaskQuery < Task::BaseQuery
def incomplete
completed_at.is_nil
end
def complete
not.incomplete
end
end
```
Is it possible to invert named scope results? Or is the best practice here to keep it explicit with completed_at.is_not_nil?
This is a relatively common convention for tracking boolean states with timestamps like approval, completion, acceptance, etc, so it'd be really handy to make that a touch easier!
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 by tracing named-scope behavior from Task::BaseQuery and the incomplete/complete examples in the issue. Define done as a tested, supported way to invert a named scope with `not`, or a clear project-supported alternative if inversion is not intended.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100