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'