# ActiveRecord find with :join creates a wrong SQL

**URL:** <https://discuss.rubyonrails.org/t/activerecord-find-with-join-creates-a-wrong-sql/48505>\
**Category:** rubyonrails-core\
**Created:** [January 11, 2010, 11:49pm UTC](https://discuss.rubyonrails.org/t/activerecord-find-with-join-creates-a-wrong-sql/48505 "2010-01-11T23:49:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tatsuya\_Ono](https://avatars.discourse-cdn.com/v4/letter/t/e79b87/32.png) [@Tatsuya\_Ono](https://discuss.rubyonrails.org/u/Tatsuya_Ono)\
**Post date:** [January 11, 2010, 11:49pm UTC](https://discuss.rubyonrails.org/t/activerecord-find-with-join-creates-a-wrong-sql/48505/1 "2010-01-11T23:49:11Z")

</div>

I ran into an issue which ActiveRecord find method creates wrong SQL when you set has\_one association which through belong\_to association into :join option.

Detail, tests and fix are here. [https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3684-invalid-sql-is-created-when-you-set-has\_one-through-association-to-join](https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/3684-invalid-sql-is-created-when-you-set-has_one-through-association-to-join)

Can someone take a look at it and give me thoughts?

Tatsuya
