This project is archived and is in readonly mode.
SomeModel.select fails to limit field with includes
-
Eugene Magdel
RECEIVED:
[# ProcessedTransaction id: 76105, raw_transaction_id: 38058, category_id: nil, amount: -21588, transaction_order: 0, automatic_fill: false ] -
x37v
I've noticed the same thing with .joins + .limit
I've created a test app (attached) which shows the problems [test/unit/user_test.rb]
This FAILS:
assert_equal User.find_by_sql(User.joins(:user_foo).limit(12).to_sql).size, User.joins(:user_foo).limit(12).sizeOn the console, oddly, if I assign the Relation to a variable and then test .size on it, I get the correct result.
in the console rails c test:
u = User.joins(:user_foo).limit(12) => ....
u.size => 12
u.size == User.joins(:user_foo).limit(12).size => falseBut in the test this fails:
u = User.joins(:user_foo).limit(12)
assert_equal 12, u.sizeIn the mean time, a work around, is to wrap in User.find_by_sql(User.joins(:user_foo).limit(12).to_sql)
-
Neeraj Singh
@Eugene
Can you post migration and model for the ProcessedTransaction and RawTransaction? I will look into this issue.
-
Santiago Pastorino
- State changed from new 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.
-
Santiago Pastorino
- State changed from open to stale
