# association preloading problems.

**URL:** <https://discuss.rubyonrails.org/t/association-preloading-problems/23882>\
**Category:** rubyonrails-core\
**Created:** [January 26, 2008, 12:39pm UTC](https://discuss.rubyonrails.org/t/association-preloading-problems/23882 "2008-01-26T12:39:01Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Frederick\_Cheung](https://sea2.discourse-cdn.com/rubyonrails/user_avatar/discuss.rubyonrails.org/frederick_cheung/32/3901_2.png) [@Frederick\_Cheung](https://discuss.rubyonrails.org/u/Frederick_Cheung)\
**Post date:** [January 26, 2008, 12:39pm UTC](https://discuss.rubyonrails.org/t/association-preloading-problems/23882/1 "2008-01-26T12:39:01Z")

</div>

- first off there are some patches on [http://dev.rubyonrails.org/attachment/ticket/9640](http://dev.rubyonrails.org/attachment/ticket/9640) that look sane to me (and maybe have slipped under the radar because they weren't in their own ticket). Secondly it has been very rightly pointed out that the include\_eager\_conditions? and include\_eager\_order? functions that preloading leans on to decide whether to fallback to the old eager loading code aren't smart enough (specifically they understand other\_table.foo, but not `other_table`.`foos`). It's not as completely straightforward as adding that to the regex (currently /([\.\w]+)\.\w+/) since the change to be made obviously depends on how that particular database quotes table & column names. Anyone have a smart idea for generating the right regular expression ? perhaps lean on connection.quote\_table\_name and connection.quote\_column\_name to generate the right delimiters and then the expression is

/#{table\_delimiter}?([\.\w]+)#{table\_delimiter}?\.#{column\_delimiter}?\w+#{column\_delimiter}/

Or is that an oversimplification of quoting ? Thoughts?

Fred

---

<div class="post-metadata">

**Author:** ![Michael\_Koziarski1](https://avatars.discourse-cdn.com/v4/letter/m/aca169/32.png) [@Michael\_Koziarski1](https://discuss.rubyonrails.org/u/Michael_Koziarski1)\
**Post date:** [January 27, 2008, 2:27am UTC](https://discuss.rubyonrails.org/t/association-preloading-problems/23882/2 "2008-01-27T02:27:07Z")

</div>

> - first off there are some patches on [http://dev.rubyonrails.org/attachment/ticket/9640](http://dev.rubyonrails.org/attachment/ticket/9640) &nbsp;&nbsp;that look sane to me (and maybe have slipped under the radar because they weren't in their own ticket).

It's probably best if the original ticket is closed and someone opens a new-rationalised patch with the changes rolled into one diff. The feature is in edge now, so these are bugs.

> /#{table\_delimiter}?([\.\w]+)#{table\_delimiter}?\.#{column\_delimiter}? \w+#{column\_delimiter}/
> 
> Or is that an oversimplification of quoting ?

I think [Some table Name] is a method of quoting used by sql server?

> Thoughts?

Inspecting the :conditions hash is kinda nice, from a usability point of view as it makes the feature 'drop in'. But it's probably a very difficult thing to get right consistently, perhaps it's worth just immediately turning it off if there's a :conditions or :order, but providing a :preload=\>true argument to find to make it work?
