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.

This project is archived and is in readonly mode.

Active record dynamic finder symbol gets converted to yaml

#3940

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

Reported by bterkuile · February 12th, 2010 @ 12:22 PM

State: committed
Milestone: 3.0.2
Assigned to: Aaron Patterson Aaron Patterson
Importance: Low

Activity

  1. Rainer Blessing
    Rainer Blessing
    • 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.

    August 3rd, 2010 @ 07:50 PM

  2. Aaron Patterson
    Aaron Patterson
    • Importance changed from to Low

    Thanks. I've applied this to the 3-0-stable branch.

    August 3rd, 2010 @ 10:57 PM

  3. Aaron Patterson
    Aaron Patterson
    • State changed from new to committed
    • Assigned user set to Aaron Patterson
    • Milestone cleared.

    oops, forgot to close.

    August 3rd, 2010 @ 10:58 PM

  4. Jeremy Kemper