luckyframework / luckyframework/avram
Unable to use `only_kept` more than once in a query
Open
Nobody has claimed this yet.
bug
- Dominant language
- Crystal
- Stars
- 183
- Forks
- 67
- PR merge metrics
- No merged PRs in 30d
Description
This query returns the wrong SQL
User::BaseQuery.new.only_kept.hide(false).or(&.only_kept.featured(true))
Should return
SELECT * FROM users WHERE soft_deleted_at IS NULL AND hide = 'f' OR soft_deleted_at IS NULL AND featured = 't';
Actually returns
SELECT * FROM users WHERE hide = 'f' OR soft_deleted_at IS NULL AND featured = 't';
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 at src/avram/soft_delete/query.cr#L18 and reproduce the query shown in the issue. Compare the generated SQL with the expected SQL, then verify that using only_kept on both sides of the or condition preserves both soft_deleted_at IS NULL predicates.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- crystal
- Domain
- databases
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100