Menu

Using OR in UserCondition

Help
2006-05-11
2013-04-23
  • Marshall Stack

    Marshall Stack - 2006-05-11

    I have a need for a couple of AND conditions plus one or more OR conditions within the same authorization. I can get multiple ANDs working in a single line like this:

    AuthMySQLUserCondition "condition1='true' AND condition2='true'"

    or as multiple lines like this:

    AuthMySQLUserCondition condition1='true'
    AuthMySQLUserCondition condition2='true'

    However, everything fails if I try this:

    AuthMySQLUserCondition "condition1='true' OR condition2='true'"

    Is there a way to sneak an OR in there someplace?

     
    • Marshall Stack

      Marshall Stack - 2006-06-09

      So WTF??? Are the people who wrote this module dead or something? Why no response in nearly a month?

       
    • Jerry Stuckle

      Jerry Stuckle - 2006-10-17

      We're doing the best we can to support this project.  But this is a voluntary project, and paying customers must come first.  Unfortunately, it means sometimes free projects like this have to be set aside, and occasionally for an extended period.

      Of course, if you can do a better job you are quite welcome to work on it yourself.

      As for your user conditions - the module wasn't designed to do that, but I see no reason why it wouldn't work.  You probably need parens around your entire condition, though.

       
    • Marshall Stack

      Marshall Stack - 2006-10-24

      I appreciate your volunteer efforts. I work 16-18 hours a day myself. If I was qualified to program in low-level languages, I would assist, however, I'm strictly a Perl hack.

      Sounds like adding () would work, but since the AND condition does not seem to require them, there was no logical reason for me to consider that an OR or any other operator might. This inquiry was posted 5 months ago and the project was time-sensitive, so I had to redesign the system to work around the problem.

      Can I suggest adding this solution to the README so the next guy who needs a logical OR doesn't have to reinvent the wheel as well?

       
    • Jerry Stuckle

      Jerry Stuckle - 2006-10-25

      No, it's simple precedence.  And it has nothing to do with low level languages - it's all SQL.

      AND/OR precedence in SQL is the same in most languages - left to right. We already need to add some of our conditions.  User conditions are ANDed to the existing ones.

      So, you end up with something like:

        ourcondition=something AND yourcond1=TRUE OR yourcond2=TRUE

      If yourcond2=TRUE is met, it doesn't matter what ourcondition=something is.  The statement will evaluate as true, whereas

        ourcondition=something AND (yourcond1=TRUE OR yourcond2=TRUE)

      ourcondition=true must be met and either of your conditions must be met.

      OTOH, if you have

        ourcondition=something AND yourcond1=TRUE AND yourcond2=TRUE

      all three conditions must be met.  It's a simple matter of understanding basic SQL.

      We will consider a note in the next release.

      BTW - I'm not sure why the following would work:

      AuthMySQLUserCondition condition1='true'
      AuthMySQLUserCondition condition2='true'

      You should get one or the other - but not both.

      Jerry

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.