infinitered / cdq

Core Data Query for RubyMotion
MIT License
172 stars 35 forks source link

Relationship queries: easier to scope/chain #131

Open dam13n opened 8 years ago

dam13n commented 8 years ago

issue: https://github.com/infinitered/cdq/issues/130

So after figuring out a workaround, I finally took a look at the specs and noticed this test

it "should be able to use named scopes" do
      cdq(@author).articles.all_published.array.should == [@article1, @article2, @article3]
end

While this can address the problem, I think it could get dirty. For example:

cdq(cdq(@author).articles.all_published.first).comments.positive.array

Instead of easily chaining, you have to cdq() wrap for each depth level.

I modified CDQRelationshipQuery slightly to fix this (not sure if it is a smart way to do it) and added a spec line.