5 Operators
The PyDO.operators module consists of support code to let you
do more with the getSomeWhere and getTupleWhere
static methods of PyDO objects. These are no more than SQL-generating
routines, and hence fall into the category of syntactic sugar, but
they can be convenient in some circumstances.
The below are SQLOperator subclasses for use with the getSomeWhere method:
- NOT
- takes one argument, the item to negate.
- EQ
- takes two arguments, the items to compare for equality.
- NE
- takes two arguments, the items to compare for inequality.
- LT
- takes two arguments, the items to compare for less than.
- LT_EQ
- takes two arguments, the items to compare for less than or
equal to.
- GT
- takes two arguments, the items to compare for greater than.
- GT_EQ
- takes two arguments, the items to compare for greater than
or equal to.
- LIKE
- takes two arguments, the first a FIELDand the second,
a string that is the LIKE matcher.
- IN
- takes two arguments, the first a FIELD, and the second,
a SET constructed with the items that should
be checked for membership. In short, the SQL IN operator.
- AND
- Takes two arguments, two sub expressions to logically and.
- OR
- Takes two arguments, two sub expressions to
logically or.
- PLUS, MINUS, MULT, DIV
- Takes two arguments, both of them either numerical constants
or a FIELD. The values will be mathematically operated on as appropriate.
Two other classes exist to control the escaping of SQL output. The
FIELD class is used to indicate that a given string is not a
string literal, but the name of a database column. The SET
class is used to generate a properly formatted list of things to use
as the second argument of the IN operator.
getTupleWhere does not use thes SQLOperator subclasses, but directly
inserts the operator strings provided by the user into the generated
SQL. The FIELD and SET classes are still needed, however.