lverweijen / ODataQuery

Query on R OData

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use default operator in binop_query

lverweijen opened this issue · comments

Building on #9 it might be convenient to have a default operator in simple queries. The default operation can always be overwritten when required.

So that the following queries give the same result:

and_query(a=3)  # Proposed
and_query(a.eq = 3)
and_query('a eq 3')

For scalars the most logical default operator is eq.
For vectors, it should probably use in instead of eq.
This seems to rhyme well with the R convention that a scalar is just a vector of length 1.

So that:

and_query(FirstName = c("John", "James"))  # Proposed
and_query(FirstName.in = c("John", "James"))
and_query("FirstName in ('John', 'James')")

Al give the same result.

Empty vectors should probably use in as well (although the sample ODataService at odata.org doesn't seem to support this):

and_query(FirstName = vector())  # Proposed
and_query("FirstName in ()")

However null should use eq (even though c() is equivalent to NULL in R):

and_query(FirstName = c())  # Proposed
and_query(FirstName = NULL)  # Proposed
and_query("FirstName eq null")