Displaying 20 results from an estimated 200 matches similar to: "A few fixes to eager loading issues"
2010 Jul 08
25
Prepared SQL statements
Dear all great developers.
I wonder if there is any work being done or thoughts being shared
regarding prepared SQL statements.
Currently I am in heavy need of tuning SQL INSERTS that insert large
(3MB) images into blobs.
I am using rails 2.3.5 with postgres adapter and pg driver.
Any information would be appreciated.
Jarl
--
You received this message because you are subscribed to the
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
2010 Oct 11
0
undefined method `includes_values' for :conditions:Symbol
Rails 3 / Ruby 1.9.2
Over the weekend I saw the "undefined method `includes_values''
for :conditions:Symbol" error for the 1st time while working with
AAF.
http://j-k.lighthouseapp.com/projects/45560-acts-as-ferret/tickets/176-aaf-051-undefined-method-includes_values-for-conditionssymbol#ticket-176-4
Anyway, i fixed the query and moved on.
Today I hit the error again but I
2006 Oct 08
1
Two-way eager loading?
My problem is that I have two classes where the eager loading isn''t
working as well as I would hope...
Here are my two classes:
class Daynote < ActiveRecord::Base
belongs_to :userplace
class Userplace < ActiveRecord::Base
has_many :daynote, :dependent => true
When I show my userplaces, I want to get the associated daynotes with
them, so I am doing:
@userplace =
2007 Dec 09
0
straight join in rails
Maybe someone will find this useful:
I have a relatively complex (My)SQL query that results from having many
many :conditions and :includes, and MySQL seems to apply a wrong join
order so I wanted to force an order using the STRAIGHT_JOIN statement,
but rails doesn''t really let you do it. Having to construct this query
manually (there are 4 joins) and still have a right format for eager
2006 Jan 19
0
Limited eager loads and conditions on the eager tables
Hi,
Why are limited eager loads and conditions on the eager tables incompatible?
Doing a find(:all) without :include causes a select * query to be generated,
which means the id fields everwrite each other if associated tables are
included using :joins.
But using :include, if conditions are placed on the tables listed in :joins
then Rails throws an exception when :limit is included too.
2006 Aug 04
2
problem eager loading with sti
Here''s the setup (working off Rails 1.1.4):
Class Project
belongs_to :employee
Class Employee < Person
has_many :projects
When I try to paginate(:employees, :include =>
:projects) I get the error "Association named
''projects'' was not found; perhaps you misspelled it?"
I can :include other models that the Person class
has_many or habtm of, and if I
2006 Aug 07
1
Eager loading wierdness
Consider this problem.
I have an Item that has_many Features
I want to find all Items with a Feature name of ''foo''.
Normally you would do this..
@items = Item.find(:all, :conditions=>["features.name = ?", ''foo''],
:include=>:features)
This all works fine and dandy except for this problem.
If you do this...
<% for item in @items %>
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 =>
2006 Jun 19
0
Eager loading and acts_as_tree
Hi all,
I have a node structure which acts_as_tree. I am pulling the first
two levels under the root node with:
@root = Node.find(1, :include => [ { :children =>
[ :children, :parent ] }, :parent ])
How do I pull out the first three levels? What about four?
@root = Node.find(1, :include => [ { :children => [ { :children =>
[:children, :parent] }, :parent ] }, :parent ])
2006 Mar 01
1
Eager loading problem. Help greately appreciated
Each Timesheet has an employee. An employee has a division and a
location.
I want to find all the timesheets with a status of 2. I then iterate
over the timesheet collection and print the timesheet name, employee
name, employee divison name, and employee location name. Like so:
for t in
Timesheet.find(:all,:conditions=>"status=2",:include=>:employee)
puts timesheet.date
2006 Mar 14
3
cascading eager loading patch not working in oracle
Notice the "AS" keyword appears many times. Oracle does not support this
keyword:
ActiveRecord::StatementInvalid: OCIError: ORA-00905: missing keyword:
SELECT tim
esheets.id AS t0_r0, timesheets.start_date AS t0_r1, timesheets.status
AS t0_r2,
timesheets.cost AS t0_r3, timesheets.charge AS t0_r4,
timesheets.employee AS t0
_r5, employees.id AS t1_r0, employees.name AS t1_r1,
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/.
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
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'',
2006 Feb 14
0
Help with Eager Association
I''ve gotten eager associations to work before, but for some reason
this isn''t working out for me this time. I''ve been scratching my head
but can''t quite figure out the nuances of what works and what doesn''t
work.
I''ve got 3 models: profile, widget_configuration and widgets
profile.rb --
has_many :widget_configurations
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
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 Sep 13
1
Eager loading with acts_as_tree
So I have a model that acts_as_tree and I run a method on a collection
of all of these records. This method walks the tree and fetches the
parent/children, etc. This results in many, many duplicate SQL queries
to be executed. Is there a way to eagerly load all of these models?
Something along the lines of:
Model.find(:all, :include => [:children, :parent])
If I execute the above statement, I