similar to: using :select with :include to limit eager loading

Displaying 20 results from an estimated 7000 matches similar to: "using :select with :include to limit eager loading"

2005 Dec 14
0
eager loading all associations
Hi Railers, Is there a way to specify all relations in a :include option while find()ing? I have a model with a lot of associations, and sometimes i would like to query for all them. Something like Model.find(params[:id], :include => :all) would be nice. Alternatively, i don''t know if there is a mehod to retrieve all model''s associations, to do something like
2006 Jul 31
0
Patch for #3438: Eager loading doesn''t respect :order of associations
Hello all, I still have a patch for #3438 (eager loading doesn''t respect association orders); it passes all unit tests, and has additional unit tests with full coverage. The patch is attached. == The Bug == Author.find(1).posts != Author.find(1, :include => [:posts]).posts if Author has_many :posts, :order => anything. This means that either one must avoid eager loading or
2008 Jan 04
1
eager loading and polymorphic associations
There is a dedicated section about eager loading in the docs. A coworker discovered eager loading does not work in polymorphic associations the hard way :-) so I''ve written a patch that documents it: http://dev.rubyonrails.org/ticket/10610 There are at least a couple of tickets that implement something that would change that though: http://dev.rubyonrails.org/ticket/9640
2006 Mar 31
2
Eager loading of polymorphic associations
Polymorphic associations work great until I try to do some eager loading through :include. In my example, the interface name is ":imagehaver". Here''s my little eagerly loading find line: Image.find(params[:id], :include => :imagehaver) All it gives me is an ActiveRecord::EagerLoadPolymorphicError with no further explanation. I haven''t been able to dig up anything
2007 Apr 26
1
eager loading not working in production mode
i have an eager load query as such: @groups = ReviewQuestionGroup.find(:all, :conditions => ["review_category_id = ?", @review.category.id], :order => ''review_question_groups.position, review_questions.position'', :include => :questions) in dev mode, this works fine... i get results like @groups[0].questions.length = 13. in production, i
2006 Jun 28
4
Load IDs For Limited Eager Loading
Hi Trying to cut down on queries with eager loading and noticed the following in development.log Load IDs For Limited Eager Loading - SELECT id ....etc Followed by Load Including Associations - SELECT table.id ... etc Is this common practice? What is limted eager loading? Cheers Mark -- Posted via http://www.ruby-forum.com/.
2008 Apr 23
2
Bug in eager loading and polymorphic associations?
Hi friends, i''m usgin the edge version because i need eager loading on polymorphic associations support, but i see this: Message.find(:first, :include => :owner) #This generate this query: SQL (0.000072) SET SQL_AUTO_IS_NULL=0 Message Load (0.000389) SELECT * FROM `messages` User Load (0.001070) SELECT * FROM `users` WHERE (users.id IN (1,2)) And this Message.find(:first,
2006 Mar 26
0
Eager loading and polymorphic association
Hi all, Is it possible to do "eager loading" with polymorphic associations ? Ex : I have a Page model that acts as taggable. When I do Page.find(:all), I would like to retrieve all tags associated with a page. Thanks, Thomas. -- Posted via http://www.ruby-forum.com/.
2007 Mar 09
0
Eager loading with inheritance
In order to implement inheritance (STI was not ideal), I have implemented a solution similar to what is described in this post: http://www.ruby-forum.com/topic/73822#108686. I have one model that acts as a parent class with shared attributes, two child models with different attributes, and a module that contains shared functionality for the child models. The issue arises in creating associations
2006 Nov 28
0
Eager loading: what am I doing wrong?
I am trying to get eager loading to work. So far it does have an effect on the initial query issued - though not the desired on: it just mentions all the fields explicitly, but creates no joins: [4;36;1mCourse Load Including Associations (0.002771) [0m [0;1mSELECT courses.`id` AS t0_r0, courses.`name` AS t0_r1, courses.`reference` AS t0_r2, courses.`subject_id` AS t0_r3, courses.`course_type_id`
2006 Jul 03
0
Eager loading of ''is meant to be nil'' Associations
If I ''find'' using :include, and some included associations are null, then looping through the array executing ''if obj[i].assoc'' accesses the database for a second time (as obj.assoc is nil). eg Topic, has_many posts Post has_one email and posts = Post.find(:all, :condition => ''posts.topic_id = 10'', :include =>
2008 Apr 21
2
Eager Loading Polymorphic Associations
Hi, I''m searching for a method of eager loading polymorphic associations under activerecord 2.0.2. After some initial google-fu I came up with a link to an enhancement that''s been added to edge: http://dev.rubyonrails.org/ticket/8119 Anyone have any idea how long that might take to work its way into a general release? I''m early in development now so I can afford to
2008 Nov 12
5
dynamic condition for has_one and eager loading issue
Hi, I ve defined the following relation in one of my models with a dynamic where condition: has_one :selection, :foreign_key => ''object_id'', :conditions => ''selection_type = 1 and account_id = # {self.send(:account_id)}'' That works perfect, however when I try to eager load that relation I am getting the following error when doing a
2006 Mar 13
4
Find and eager loading questions
Hi all, I want to see if I''m not missing something with associations and eager loading. (I''m currently using Locomotive on OS X and SQLite3.) I have two simple tables/models, set up properly: teams has_many :matches and matches belongs_to :teams. Matches has a match number and a team_id field (along with several other fields) and teams has a team_number field (again, along with
2007 Dec 12
2
possible bug in eager loading
Hello, @users = User.find(:all, :include => {:user_data => :user_data_field}, :order => "username = ''someone-oHC15RC7JGTNLxjTenLetw@public.gmane.org'' desc", :limit => 50) This produces: User Load IDs For Limited Eager Loading (74.648762) SELECT * FROM (SELECT DISTINCT ON (users.id) users.id, username AS alias_0 FROM users LEFT OUTER JOIN
2010 Oct 25
1
A few fixes to eager loading issues
Hey all, I''d really appreciate some eyes on https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/5845-activerecord-3-eager-loading-fail#ticket-5845-19. There''s a small issue in Rails 3 eager loading, and this ticket has an accompanying patch. Sssociations that show up twice in a Relation chain like: Article.includes(:comments).includes(:comments =>
2005 Aug 04
1
Pagination and :include (eager associations)
I have tried to use eager association with pagination, but the :include option is not supported: Here''s the one-line pagination call without :include @link_pages, @links = paginate :link, :per_page => 10, :order_by => sort_clause and here the work around, using the "classic" method # @link_pages = Paginator.new self, Link.count, 10,
2007 Nov 08
0
Dynamic relation with eager loading
A model has 2 columns in its table asset_type_id asset_id the asset_type_id links directly to the table asset_types via a belongs_to asset_types contains a single column ''name'' method_missing in the model says when you call a method matching /^asset.*/ call the corresponding method substituting ''asset'' for the contents of asset_type.name (ie. the name in
2006 Feb 10
1
Eager loading issue
I have three tables, Invoices, Projects, and Managers. Each manager has many projects. Each project has many invoices. When displaying a list of the invoices, I am using: Invoice.find(:all, :include => [:project]) Since the list shows information from the project table. (For example, a table showing Invoice Date, Project Name). However, I''d also like to show the manager name.
2006 Feb 12
3
Error when Eager Loading "Not unique table/alias"
Hi list, I get the error "Not unique table/alias" (myql 4.1) when trying eager load 2 classes that use the same base class (not STI) Example: <code> class Wedding < ActiveRecord::Base belongs_to :bride, :class_name => ''Person'', :foreign_key => ''bride_id'' belongs_to :groom, :class_name => ''Person'',