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.

Support of OR as condition connector in merge_conditions

#3122

This patch allows you to choose between AND or OR as condition connector in merge_conditions. No need to change your code if you don't want to use OR as connector with the new patched method.

Reported by Lennart Koopmann · August 31st, 2009 @ 06:15 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Kane
    Kane

    interessing.. but i dont like the syntax :connector => "OR" cant it be a symbol?
    and just defaulting to and if its nor and or or feels strange, the developer should be noticed about his error otherwise he wonders why he didnt get back what he expected.

    September 1st, 2009 @ 12:19 AM

  2. Lennart Koopmann
    Lennart Koopmann

    I made the :connector parameter optional because currently AND is the standard connector. I don't know what the usual way for Rails is but my experience says that it's better to keep the default behaviour and add the new function as an not required option.

    I'll create a new patch that makes the :connector a symbol.

    September 1st, 2009 @ 01:18 PM

  3. Kane
    Kane
        # Only allow AND or OR as connector. Default to AND.
        connector = "AND" unless connector == "AND" or connector == "OR"
    

    i meant this line of code, if i put some other thing into it, say:

    Product.merge_conditions :conditions => conditions, :connector => :xor

    i end up with the connector "and", but i specified "xor".

    you are absolutely right it doesnt makes any sense to require the connector option and it should indeed default to 'and', but if i explicitly specify it, it should not simply be set to 'and' cause its not 'and' or 'or'.

    There is more then 'and' and 'or' and i would suggest just setting it to 'and' if no connector is set else just use the passed operator.

    September 1st, 2009 @ 02:56 PM

  4. Lennart Koopmann
    Lennart Koopmann

    Ah, okay. That's true. I'll also change that in the next patch. :)

    September 1st, 2009 @ 03:31 PM

  5. Lennart Koopmann
  6. Lennart Koopmann
    Lennart Koopmann

    Previous patch deleted. Here is the new one (Changed email address)

    September 1st, 2009 @ 04:15 PM

  7. Josh Sharpe
    Josh Sharpe

    -1 applies cleanly to master
    breaks existing tests
    no new tests

    September 1st, 2009 @ 08:12 PM

  8. Lennart Koopmann
    Lennart Koopmann

    All the tests run fine for me. Which fail on your system?

    September 2nd, 2009 @ 09:46 AM

  9. CancelProfileIsBroken
    CancelProfileIsBroken
    • Tag changed from patch to bugmash, patch

    September 25th, 2009 @ 12:37 PM

  10. Rizwan Reza
    Rizwan Reza
    • Tag changed from bugmash, patch to activerecord, feature, patch
    • State changed from new to open

    The patch applies with some whitespace errors. Please provide tests also. Thanks!

    January 21st, 2010 @ 07:09 AM

  11. Kane
    Kane

    this is no longer relevant since arel or is it?
    I think it can be closed.

    June 15th, 2010 @ 06:26 PM

  12. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 11th, 2010 @ 10:56 AM

  13. Jeff Kreeftmeijer
    Jeff Kreeftmeijer
    • Title changed from [PATCH] Support of OR as condition connector in merge_conditions to Support of OR as condition connector in merge_conditions
    • Tag set to activerecord, patch

    Using the "patch" tag instead of prefixing the ticket title with "[PATCH]" to make sure patched tickets end up in the open patches bin. :)

    October 12th, 2010 @ 06:58 AM

  14. Santiago Pastorino
    Santiago Pastorino

    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.

    February 9th, 2011 @ 12:31 AM

  15. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 9th, 2011 @ 12:31 AM

  16. bingbing