Use of projection dsl is not available in Relation#exclude
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 42/100
Research direction
Start at Relation#exclude and the projection DSL shown in the reproduction, then reproduce the query to trace where the block is evaluated. Add coverage for the expected NOT (1 = ANY(...)) SQL and confirm the projection and existing conditions remain unchanged.
Written by the indexing model from the issue text.
Description
Describe the bug
It I try to use the projection dsl in combination with #exlude...
mentions
.select { integer::count(issue_id).as(:unit_mention_count) }
.where(unit_id: 3, read: false)
.exclude { user_ids.any(1) }
...I get the following error:
NoMethodError:
undefined method `any' for #<Sequel::SQL::Identifier @value=>:user_ids>
.exclude { user_ids.any(1) }
Expected behavior
SELECT COUNT(\"mentions\".\"issue_id\") AS \"unit_mention_count\" FROM \"mentions\" WHERE ((\"unit_id\" = 3) AND (\"read\" IS FALSE) AND NOT (1 = ANY(\"mentions\".\"user_ids\")))
Workaround
Overwrite #exclude at relation
class Mentions < ROM::Relation[:sql]
schema(:mentions, infer: true) do
end
def exclude(*args, &block)
if block
exclude(*args).exclude(schema.canonical.restriction(&block))
elsif args.size == 1 && args[0].is_a?(Hash)
new(dataset.exclude(coerce_conditions(args[0])))
elsif !args.empty?
new(dataset.exclude(*args))
else
self
end
end
end
WDYT? I could provide a PR.
- Dominant language
- Ruby
- Stars
- 220
- Forks
- 97
- PR merge metrics
- No merged PRs in 30d
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.
More from rom-rb/rom-sql
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 48/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 4/5 3-5 days Newbie friendliness 42/100
-
bug help wanted
Difficulty 3/5 1-2 days Newbie friendliness 45/100
Similar issues
-
バグ
Difficulty 1/5 Under an hour Newbie friendliness 92/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
voxpupuli/puppet-epel#186 · 1 comment ·
-
external_created_at is no longer used for the message timestamp since the new message UI (v4.4.0) OpenBug Frontend
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
TheOdinProject/curriculum#31402 · 1 comment ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100