tdfs4ds.feature_props.valtypes¶
tdfs4ds.feature_props.valtypes
¶
Value families and bounds of feature properties (pure, no database).
A declared bound (VALID_MIN / VALID_MAX) or allowed value is stored as TEXT and compared
after being typed like the feature: this module says which family a catalog FEATURE_TYPE
belongs to, whether a text is a valid literal of it, and how to write it in SQL.
_NUMERIC_PREFIXES
module-attribute
¶
_NUMERIC_PREFIXES = ('BYTEINT', 'SMALLINT', 'INTEGER', 'INT', 'BIGINT', 'FLOAT', 'REAL', 'DOUBLE', 'DECIMAL', 'DEC', 'NUMERIC', 'NUMBER')
_TS_RE
module-attribute
¶
_TS_RE = re.compile('^(\\d{4})-(\\d{2})-(\\d{2})(?:[ T](\\d{2}):(\\d{2}):(\\d{2})(\\.\\d+)?)?\\s*(Z|[+-]\\d{2}:\\d{2})?$')
sql_literal
¶
Escape value for use inside a single-quoted SQL string literal.
For the DBC probes and catalog predicates that compare a name as data
(WHERE DatabaseName = '…'). The caller supplies the surrounding quotes.
family_of
¶
'numeric' / 'date' / 'timestamp' / 'text' for a catalog FEATURE_TYPE,
None for anything a range or an allowed list cannot express (PERIOD, JSON, BLOB, ...).
check_literal
¶
(ok, normalised text, reason): is text a valid literal of the feature's type?
numeric: a finite number (decimals allowed for integer features: the comparison is numeric);
date: YYYY-MM-DD; timestamp: ISO date or date-time, optional offset; text: any non-empty
text. A type with no family (PERIOD, JSON, LOB...) refuses every bound.
sql_value
¶
The SQL expression of a declared value, typed like the feature. Pure; text must have
passed :func:check_literal.
bounds_order_ok
¶
False when both bounds are given, comparable and VALID_MIN > VALID_MAX.