This project is archived and is in readonly mode.
fixed counter_sql from finder_sql to work with subselects
-
Pratik
Hey,
The patch doesn't apply cleanly. Also, could you please fix your email in the patch ?
git config --global user.name "Your Name" git config --global user.email your_email@your-domain.com -
Kane
- Assigned user set to Pratik
-
Pratik
- State changed from new to incomplete
Hey Kane,
The tests fail on sqlite3. I think the test should be skipped for adapters not supporting subqueries.
Thanks!
-
Kane
are there adapters which dont support subqueries?
I changed the sql, now works with sqlite3 and should not be adapter specific.
hope this is the final version^^
-
Pratik
The test still fails for me on sqlite3.
1) Error: test_counting_from_finder_sql_with_subselect(HasManyAssociationsTest): ActiveRecord::StatementInvalid: SQLite3::SQLException: near ")": syntax error: SELECT COUNT(*) FROM companies LIMIT 1) IS NOT NULL; ./cases/../../lib/active_record/connection_adapters/abstract_adapter.rb:214:in `log' ./cases/../../lib/active_record/connection_adapters/sqlite_adapter.rb:168:in `execute_without_query_record' ./cases/../../lib/active_record/connection_adapters/sqlite_adapter.rb:413:in `catch_schema_changes' ./cases/../../lib/active_record/connection_adapters/sqlite_adapter.rb:168:in `execute_without_query_record' ./cases/helper.rb:41:in `execute' ./cases/../../lib/active_record/connection_adapters/sqlite_adapter.rb:316:in `select' ./cases/../../lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache' ./cases/../../lib/active_record/connection_adapters/abstract/query_cache.rb:62:in `select_all' ./cases/../../lib/active_record/connection_adapters/abstract/database_statements.rb:13:in `select_one' ./cases/../../lib/active_record/connection_adapters/abstract/database_statements.rb:19:in `select_value' ./cases/../../lib/active_record/base.rb:956:in `count_by_sql' ./cases/../../lib/active_record/associations/association_collection.rb:169:in `count' cases/associations/has_many_associations_test.rb:36:in `test_counting_from_finder_sql_with_subselect' ./cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `__send__' ./cases/../../lib/../../activemodel/lib/../../activesupport/lib/active_support/testing/setup_and_teardown.rb:62:in `run' -
Kane
strange, i only get this error without the fix.
-
Kane
i rebased and removed a conflict.
also 2 other developers tried my patch and they got no error.
i have no idea why its failing on your machine.tested on:
windows xp, ruby 1.8.6, sqlite3-ruby 1.2.5 with sqlite 3.5.6
ubuntu, ruby 1.9.1, sqlite3-ruby 1.2.4 with sqlite 3.6.10 -
Kane
this is still an issue in edge..
-
Kane
- Assigned user changed from Pratik to Jeremy Kemper
-
Neeraj Singh
- Importance changed from to
@Kane can you provide an example of "subselects in the finder_sql" so I could fully understand the problem this patch is solving. If I understand it then I can write a test for your patch.
Thanks
-
Kane
SELECT * FROM articles WHERE id IN (SELECT article_id FROM comments WHERE text LIKE '%test%');
-
rails
- State changed from incomplete to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
rails
- State changed from open to stale
