|
/ modules / paradigms / Numeric_Straight.py
SYNOPSIS
Numeric_Straight (table, idColumn, valueColumn, units, cardinality)
table
A table to query, e.g., "holding".
idColumn
The table's object identifier column (i.e., the column
to be selected), e.g., "holding_id".
valueColumn
The table's value column (i.e., the column against which
the constraint is to be placed), e.g., "resolution".
units
A dictionary that maps units of measure (as strings) to
multiplicative conversion factors (as floats). For
example, if the value column is stored in meters, the
units dictionary might be:
{ "meters" : 1.0,
"centimeters" : 0.01,
"inches" : 0.0254 }
cardinality
A Cardinality object representing the cardinality of
'table' with respect to 'valueColumn'.
DESCRIPTION
Translates a numeric constraint to an SQL numeric comparison.
Given a numeric constraint (B, O, V [, U]) where B is a numeric
bucket, O is one of the six standard relational operators, V is
a real number, and U is an optional unit of measure, this
paradigm converts V to the unit of measure used by the table's
value column and returns the following query:
SELECT idColumn FROM table
WHERE valueColumn op Vconv
where 'op' is the SQL equivalent of O and 'Vconv' is the
converted value of V.
Exceptions thrown:
unsupported unit of measure
AUTHOR
Greg Janee
gjanee@alexandria.ucsb.edu
HISTORY
$Log: Numeric_Straight.py,v $
Revision 1.1 2002/10/01 18:30:53 gjanee
Initial revision
|