• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

take-five / activerecord-hierarchical_query
100%
master: 94%

Build:
Build:
LAST BUILD BRANCH: v0.2.0
DEFAULT BRANCH: master
Repo Added 07 Mar 2014 01:09PM CUT
Files 11
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

LAST BUILD ON BRANCH support-default-scopes-order
branch: support-default-scopes-order
CHANGE BRANCH
x
Reset
  • support-default-scopes-order
  • fix-travis-ci-build
  • master
  • pull-request-11-branch
  • rails-4
  • rails-5
  • rails-5-upcoming
  • v0.0.1
  • v0.0.2
  • v0.0.3
  • v0.0.4
  • v0.0.5
  • v0.0.6
  • v0.0.7
  • v0.0.8
  • v0.1.0
  • v0.1.1
  • v0.1.2
  • v0.1.3
  • v0.2.0
  • v1.0.0
  • v1.0.1
  • v1.1.0

pending completion
78

push

travis-ci

take-five
Discard default scope order from recursive query

Given a model with default scope:
```
class LinkedItem < ActiveRecord::Base
  belongs_to :parent, class_name: 'LinkedItem', foreign_key: :parent_id
  default_scope -> { order('name ASC') }
end
```

When trying to build hierarchical query against this model
Builder applied default scope to recursive part of recursive query
which lead to invalid SQL queries:
```
SELECT "linked_items".* FROM "linked_items" INNER JOIN (WITH RECURSIVE "linked_items__recursive" AS ( SELECT "linked_items"."id", "linked_items"."parent_id" FROM "linked_items" WHERE "linked_items"."id" = $1 UNION ALL SELECT "linked_items"."id", "linked_items"."parent_id" FROM "linked_items" INNER JOIN "linked_items__recursive" ON "linked_items__recursive"."parent_id" = "linked_items"."id"  ORDER BY name ASC ) SELECT "linked_items__recursive".* FROM "linked_items__recursive") AS "linked_items__recursive" ON "linked_items"."id" = "linked_items__recursive"."id"
```

This commit removes any default ordering when applying default scope to
CTE terms.

393 of 394 relevant lines covered (99.75%)

212.32 hits per line

Relevant lines Covered
Build:
Build:
394 RELEVANT LINES 393 COVERED LINES
212.32 HITS PER LINE
Source Files on support-default-scopes-order
  • List 0
  • Changed 0
  • Source Changed 0
  • Coverage Changed 0
Loading...
Coverage∆FileLinesRelevantCoveredMissedHits/Line
No data available in table
Showing 0 to 0 of 0 entries
  • Previous
  • Next

Recent builds

Builds Branch Commit Type Ran Committer Via Coverage
78 support-default-scopes-order Discard default scope order from recursive query Given a model with default scope: ``` class LinkedItem < ActiveRecord::Base belongs_to :parent, class_name: 'LinkedItem', foreign_key: :parent_id default_scope -> { order('name ASC') } end ``` ... push 10 Nov 2016 08:36AM CUT take-five travis-ci pending completion  
See All Builds (91)
  • Repo on GitHub
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc