normalize all Numeric types to return Decimal

Issue #646 resolved
Mike Bayer repo owner created an issue

first, confirm that psycopg2 does in fact return Decimal objects for postgres numeric types. then, modify types.Numeric to perform this conversion for everyone else who normally returns a float. the PGNumeric type will override convert_bind_param() and convert_result_value() to do nothing.

Comments (5)

  1. Mike Bayer reporter

    implemented for sqlite, pg and mysql in changeset:3030. both pg and mysql were already following the behavior of Numeric to return Decimal, Float to return float(). an "asdecimal" flag was added so that both Numeric and Float can return either, while still retaining the default behavior of Decimal/float for Numeric/Float, getting it to work on sqlite too. both Decimal/float are accepted for all Numeric/Float types as bind parameters at all times (again, only sqlite needed this).

    when the test suite is run for oracle, mssql, firebird, and informix, those dialects can be adjusted to suite the Numeric test in test/sql/testtypes.py.

  2. Log in to comment