New submission from wrobell: Numeric type conversion does not always work when using SQLite module.
Let's assume schema: create table test_num(no numeric); Fetching a `test_num.no` table gives float by default. Now, let's register some converter sqlite3.register_converter('numeric', lambda d: Decimal(d)) Fetching `test_num.no` gives Decimal. But change `test_num.no` type to `numeric(10, 2)`. Float is returned. This can be fixed by sqlite3.register_converter('numeric(10,', lambda d: Decimal(d)) But above will fail for `test_num.no: numeric(10,2)', which works in case of sqlite3.register_converter('numeric(10,2)', lambda d: Decimal(d)) SQLite module's cursor object type cast mechanism breaks declared type after first space {i.e. "numeric(10, 2)" -> "numeric(10,"} and then looks up registered type converter using the first "word". The simple fix for above could be to perform the break after space or "(" character. Patch attached. ---------- components: Library (Lib) files: python-sqlite-numeric.patch messages: 62640 nosy: wrobell severity: normal status: open title: sqlite numeric type conversion problems versions: Python 2.5 Added file: http://bugs.python.org/file9484/python-sqlite-numeric.patch __________________________________ Tracker <[EMAIL PROTECTED]> <http://bugs.python.org/issue2157> __________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com