This project is archived and is in readonly mode.

#110 ✓resolved
John Devine

Scan custom select to ensure included tables are joined

Reported by John Devine | May 4th, 2008 @ 08:11 PM

Came across this when using GeoKit to inject a derived distance attribute into an active record when the distance was calculated by the lat/lon of an associated object. Worked before the new eager loading with limited ids changes.

def test_with_limiting_with_custom_select

assert_equal(3,

Post.find(:all,

:include=>:author,

:select=>' posts.*, authors.id as "author_id"',

:limit=>3).size

end

fails with:

test_with_limiting_with_custom_select(FinderTest):

ActiveRecord::StatementInvalid: PGError: ERROR: missing FROM-clause entry for table "authors" at character 18

: SELECT posts.*, authors.id as "author_id" FROM "posts" LIMIT 3

./test/cases/../../lib/active_record/connection_adapters/abstract_adapter.rb:151:in `log'

./test/cases/../../lib/active_record/connection_adapters/postgresql_adapter.rb:446:in `execute_without_counting'

./test/cases/helper.rb:38:in `execute'

./test/cases/../../lib/active_record/connection_adapters/postgresql_adapter.rb:883:in `select_raw'

./test/cases/../../lib/active_record/connection_adapters/postgresql_adapter.rb:870:in `select'

./test/cases/../../lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'

./test/cases/../../lib/active_record/connection_adapters/abstract/query_cache.rb:55:in `select_all'

./test/cases/../../lib/active_record/base.rb:567:in `find_by_sql'

./test/cases/../../lib/active_record/base.rb:1322:in `find_every'

./test/cases/../../lib/active_record/base.rb:520:in `find'

./test/cases/finder_test.rb:869:in `test_with_limiting_with_custom_select'

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

Pages