Re: Parenthesis in queries.

From: Daniel Lorimer (thelorime..mail.com)
Date: Wed Jul 06 2005 - 09:18:54 EDT

  • Next message: Todd O'Bryan: "Re: DataObject states"

    OK, I guess I'll just have to work with that.
    Thanks!

    Like I said, the parsing fails on the parenthesis, is there a reason that
    parenthesis are not allowed? (i.e. it would mess up something else in the
    expression or possibly the whole expression) Or is it just not allowed just
    because?

    What I mean is, if I could force an expression like this: (somehow, I don't
    know)
    MONTH(birthDate) = '07'
    Would the query work? Is it even worth dreaming about?

    I guess I could phrase it another way.
    You say that cayenne expressions can't handle that.
    I'm curious, what is it with the expressions that can't handle it?

    I don't really understand the difference between SelectQueries and
    SQLTemplateQueries (as far as how they handle syntax), so that may be where
    my confusion lies, but it seems that if I could get the same expression into
    the SelectQuery, that it would work fine. Is this true, or is there some
    formatting thing in the SelectQuery that would throw it off.

    Or maybe I don't understand how it works, I don't know.

    Thanks for your help,
    Daniel Lorimer

    On 7/5/05, Andrus Adamchik <andru..bjectstyle.org> wrote:
    >
    > 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 : Wed Jul 06 2005 - 09:18:55 EDT