Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Scan custom select to ensure included tables are joined

#110

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'

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

State: resolved
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. John Devine
  2. Frederick Cheung
    Frederick Cheung

    Good catch! Hadn't thought of that one. I'll give it a whirl later today but looks good to me

    May 6th, 2008 @ 10:18 AM

  3. Pratik
    Pratik
    • Title changed from [PATCH] Scan custom select to ensure included tables are joined to Scan custom select to ensure included tables are joined

    May 13th, 2008 @ 01:58 PM

  4. Repository
    Repository
    • State changed from new to resolved

    (from [b28b54cab090bed8f099ef375b419a8f92390dd4]) Make sure needed table joins are included :select option. [#110 state:resolved]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    May 15th, 2008 @ 01:50 PM