Subject: CAP: search ABNF sql-min

From: Doug Royer <[email-masked]>
Date: Mon, 19 Nov 2001 12:42:35 -0700

To correct for omissions and errors I propose the following changes
to the text. I don't think I have added anything new. I think the
text below is just more accurate.

    search     = "BEGIN:VQUERY" CRLF
                 [expand] [maxresults] [maxsize] querycomp
                 "END:VQUERY" CRLF

    expand     = "EXPAND" ":" ( "TRUE" / "FALSE") CRLF
               # the default is EXPAND:FALSE

    comp-name  = "VEVENT" / "VTODO" / "VJOURNAL"
               / "VTIMEZONE" / "VALARM" / "VFREEBUSY"
               / "VCAR" / iana-name / x-name

    maxresults = "MAXRESULTS" ":" integer CRLF
		# Where integer MUST BE greater then or equal to zero.

    maxsize    = "MAXSIZE" ":" integer CRLF
		# Where integer MUST BE greater then or equal to zero.

    querycomp  = ( query ) / ( queryname query ) / queryname
                # If only queryname is supplied, then queryname
                # MUST BE an already stored VQUERY.

    queryname  = "QUERYNAME:" text

    query      = "QUERY:" ( query-min / query-92 )
    #
    # NOTE: query-min MUST be implemented in CSs.
    #
    #   query-92 is ONLY used if CAPABILITY returns SQL-92
    #   as the QUERYLEVEL value or if QUERYLEVEL is not
    #   specified.
    #

    query-min      = "SELECT" capmin-cols-wild " FROM" capmin-comps
                     "WHERE" capmin-cmp

   prop-name	= # Any property name found in any of the components.

   capmin-col     = ( prop-name
		     / comp-name "." prop-name
		     # Where: comp-name MUST BE a sub-componet
		     # of one or more of the capfrom-min values
		     # in the same VQUERY.
                     #
                     # Example: UID
		     # Example : VALARM.ALARMID
		
    capmin-col-wild  = ( capmin-col / prop-name ".*" )
		     # Example: UID
                     # Example: VALARM.ALARMID
	             # Example: VALARM.*

    capmin-cols-wild = ( capmin-col-wild
                         / capmin-col-wild "," capmin-cols-wild )
		        / ( "*")
		    # Example: UID
	            # Example: VALARM.ALARMID
                    # Example: VALARM.*
	            # Example: *   - which includes sub-components

    capmin-comps   = ( comp-name
                       / comp-name "," compmin-comps )
		     / "*"
                    # Example: VEVENT - which includes sub-components
                    # Example: *      - which includes sub-components

    capmin-cmp     = ( capmin-col cmpmin-oper colvalue
                   / capmin-col cmpmin-oper colvalue
                     capmin-logical capmin-cmp )
		   # Precedence is from left to right. And
		   # there is no grouping.
                   #
                   # Implementations MUST support at least one
		   # capmin-logical per VQUERY.
		
    cmpmin-oper    = ( " = "  / " != " / " < " / " > " / " <= "
                   / " >= " )
                   # Only times, integers, and float values may
                   # use the "<", ">", "<=", ">=' cmpmin-oper's.
                   #
		   # If times are compared, they must be compared
                   # in UTC. All implementations MUST be provided
	           # times for comparison in UTC.

    capmin-logical = ( " AND " / " OR " )

    colvalue       = # Any valid value for the column name supplied.

    query-92       = capselect-92 capfrom-92 capwhere-92
                     [ caporderby-92 ]

    capselect-92   = "SELECT " capselect-92-col

    capselect-92-col = capmin-cols-wild
                       # Plus any valid [SQL] string that goes
                       # into an SQL SELECT clause.

    capfrom-92     = "FROM " capfrom-92-cols

    capfrom-92-cols  = capmin-comps
                       # Plus any valid [SQL] string that goes 
		       # into an SQL FROM clause.

    capwhere-92    = "WHERE" capwhere-92-cols

    capwhere-92-cols = capmin-cmp
		       # Plus any valid [SQL] string that goes
		       # into an SQL WHERE clause.

# Any valid [SQL] string that goes into a
                     # WHERE clause.

    caporderby-92  = "ORDERBY"
                     # followed by any valid [SQL] string that goes
                     # into an [SQL] ORDERBY clause.

---

From: Martijn van Beers <[email-masked]>
Date: Tue, 20 Nov 2001 10:15:43 +0100

> text below is just more accurate.

[...]
>     capmin-logical = ( " AND " / " OR " )
[...]

As I wrote before,
> I was looking at the query-min syntax for the VQUERY component, and
> I was wondering how to handle AND/OR. there's no parentheses in the
> syntax, so 'expr AND expr OR expr' seem ambiguous to me. Is it
> supposed to mean '(expr) AND (expr OR expr)' or
> '(expr AND expr) OR expr'? Or are things like that just not
> allowed? I think at least some clarification is in order.

Martijn