This project is archived and is in readonly mode.
Active record dynamic finder symbol gets converted to yaml
Reported by bterkuile | February 12th, 2010 @ 12:22 PM | in 3.0.2
When playing with aasm I was trying selectors like:
MyModel.find_all_by_state :active
This returns an empty result while:
MyModel.find_all_by_state 'active'
Returned the expected results.
SQL:
SELECT * FROM "my_models" WHERE ("my_models"."state" = '---
:active')
This is for me unexpected behavior. I tracked the logic back to
the file:
activerecord/lib/active_record/connection_adapters/abstract/quoting.rb
I cannot oversee the implications of doing stuff like:
class Symbol; alias to_yaml to_s; end
Comments and changes to this ticket
-
Rainer Blessing August 3rd, 2010 @ 07:50 PM
- Tag changed from active_record, quoting to active_record, patch, quoting
The conversion of the value to YAML was there since the first commit of quoting.rb by DHH.
I changed the conversion of the value to a string and added a test for it.
There seems to be no test for the to_yaml case and the YAML conversion does not make sense to me.
The patch contains the fix and a test. -
Aaron Patterson August 3rd, 2010 @ 10:57 PM
- Importance changed from to Low
Thanks. I've applied this to the 3-0-stable branch.
-
Aaron Patterson August 3rd, 2010 @ 10:58 PM
- State changed from new to committed
- Assigned user set to Aaron Patterson
- Milestone cleared.
oops, forgot to close.
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>