Type coercion from raw user input to column's type

8 views
Skip to first unread message

Lukas Lueg

unread,
Dec 18, 2012, 4:39:30 AM12/18/12
to sqlal...@googlegroups.com
Hi,

I've to parse raw user input which ends up as filter-parameters for querys. Consider the following examples, which will end up as where-clauses against date- and decimal-columns (among others).

FooDate = 2005/12/04
FooDate = 04.12.2005
BarValue = 100,000.00$
BarValue = USD 100000


My question is >where< to put the code that will parse the right-hand-side-values and bring it to the appropriate type.

The database- and python-type can be inferred from reflection and the raw strings are parsed by regular expressions. My idea is to put this into types.TypeDecorators (e.g. process_bind_param()) so code building queries from raw user input does not have to care about doing type coercion itself.

Ideas?

Reply all
Reply to author
Forward
0 new messages