Re: Parenthesis in queries.

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Jul 05 2005 - 21:52:19 EDT

  • Next message: Dhruti Ramani: "Re: DataObject states"

    Daniel,

    As was discussed previously (http://objectstyle.org/cayenne/lists/
    cayenne-user/2005/06/0235.html) you can't use Cayenne expressions
    with MONTH and YEAR functions. Using "Expression.fromString" doesn't
    change this fact.

    So you'll have to stick with SQLTemplate for this particular query.

    Andrus

    On Jul 6, 2005, at 12:02 AM, Daniel Lorimer wrote:

    > I'm trying to build a SelectQuery with an Expression.
    >
    > What I want to do is make the expression something like:
    >
    > WHERE MONTH(birthDate) = '07'
    > WHERE YEAR(birthDate) = '2005'
    >
    > When formatted correctly it would return based only on the month
    > rather than the whole date.
    >
    > I have done this succesfully with a SQLTemplateQuery, but I want it
    > to be more versatile and match my other queries.
    >
    > So, I have attempted to make this into an expression for a
    > SelectQuery by the fromString method, but I get an ExpressionParser
    > error and it won't parse the string into an expression.
    >
    > It says:
    >
    > . . . Encountered "(" . . . .
    > Was expecting one of:
    > <EOF>
    > "or" ...
    > "and" ...
    > "not" ...
    > (etc. . . . )
    >
    > Is there some way around this?
    > Is there some way to make the ExpressionParser take a parenthesis?
    > Or is there a way I can change it so it will?
    >
    > And actually that raises another question I have:
    > If I change the parser so it will take a parenthesis, will I have
    > other problems.
    >
    > Any help with this would be greatly appreciated.
    >
    > Thanks,
    > Daniel Lorimer



    This archive was generated by hypermail 2.0.0 : Tue Jul 05 2005 - 21:52:21 EDT