
Test case for children finders
Reported by Jeremy Nicoll | August 6th, 2008 @ 09:57 AM
Just came across something that you might want to look at. In the following code, it returns the same video over and over again, which is not expected behavior. What is expected is for the first video in each category to be returned.
Category.all(:show_on_homepage => true, :order => [:section.asc, :display_order.asc] ).each do |cat|
@sections[cat.section] << cat.videos.first(:air_date.lte => Date.today, :order => [:air_date.desc])
end
The following queries are run:
~ SELECT `id`, `name`, `featuring`, `featuring_url`, `frequency`, `spotexchange_channel`, `show_on_homepage`, `section`, `display_order`, `show_bumper`, `eloop_export`, `eloop_featuring`, `meta_title`, `meta_description`, `meta_keywords` FROM `categories` WHERE `show_on_homepage` = TRUE ORDER BY `section`, `display_order`
~ SELECT `id`, `air_date`, `created_at`, `category_id`, `name`, `featuring`, `summary`, `description`, `featuring_url`, `video_uploaded` FROM `videos` WHERE `air_date` <= '2008-08-06' AND `category_id` IN ('000015', '000001') ORDER BY `air_date` DESC LIMIT 1
~ SELECT `id`, `air_date`, `created_at`, `category_id`, `name`, `featuring`, `summary`, `description`, `featuring_url`, `video_uploaded` FROM `videos` WHERE `air_date` <= '2008-08-06' AND `category_id` IN ('000015', '000001') ORDER BY `air_date` DESC LIMIT 1
As you can see, the same query is run twice. This is in 0.9.4.
Comments and changes to this ticket
-
-
-
Jeremy Nicoll August 6th, 2008 @ 11:12 AM
- no changes were found...
-
Dan Kubb (dkubb) January 8th, 2009 @ 05:07 AM
- State changed from new to accepted
- Assigned user changed from Sam Smoot to Dan Kubb (dkubb)
-
Jonathan Stott (namelessjon) February 22nd, 2009 @ 08:44 AM
- Tag changed from bug, dm-core to bug, dm-core, one_file_test
- State changed from accepted to resolved
The problem itself seems to be resolved in 0.10.0 (in that appropriate records are searched for in all cases), however, further tests did reveal a different issue for CPKs.
Ticket to follow.
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »