Re: RFC: semantic of expressions

From: Andrus Adamchik (andru..bjectstyle.org)
Date: Tue Oct 21 2003 - 12:04:48 EDT

  • Next message: Giulio Cesare Solaroli: "Re: RFC: semantic of expressions"

    Hi Giulio Cesare,

    On Tuesday, October 21, 2003, at 04:28 AM, Giulio Cesare Solaroli
    wrote:
    >
    > Item <-->> Bid <<--> User
    >
    > In this scenario, you could be interested in defining many
    > expressions; some examples:
    >
    > 2- "all items that have bids done by User whose gender is "male" and
    > whose address is in the United States.

    > Second take:
    > users = new Vector();
    > users.add(User_A);
    > users.add(User_B);
    > expression = new MatchAllValuesExpression("to_bids.to_user", users);
    > query = new SelectQuery(Item.class, expression);
    > result = dataContext.performQuery(query);

    I am more in favor of the second version too. One question though - how
    are you planning to express the "splits" that you have in the Objective
    C version? Maybe have another KeyValue expression containing the "no
    split" part, and taking MatchAllValuesExpression as its "value"? Is
    this what you have in mind?

    Another related topic. We were planning to allow expressions encoded as
    strings (e.g. "xyz.abc = ..and mnk != %@", you see what I am talking
    about). I wonder how we can express the case above (and more complex
    ones with splits) in this format as well? Add an operator for "match
    all" or something? (SQL has "ALL" operator, maybe use it too?)

    > select t0.id_item, t0....
    > from item t0, bid t1, bid t2, user t3, user t4
    > where t0.id_item = t1.id_item
    > and t1.id_user = t3.id_user
    > and t3.id_user = <id User_A>
    > and t0.id_item = t2.id_item
    > and t2.id_user = t3.id_user
    > and t3.id_user = <id User_B>

    BTW, the last join in the chain can be omitted when matching on PK,
    optimizing this query a little bit (I believe Cayenne already
    implements "no last join" policy):

          select t0.id_item, t0....
          from item t0, bid t1, bid t2
            where t0.id_item = t1.id_item
            and t1.id_user = <id User_A>
            and t0.id_item = t2.id_item
            and t2.id_user = <id User_B>

    Andrus



    This archive was generated by hypermail 2.0.0 : Tue Oct 21 2003 - 12:04:49 EDT