def result_processor(self, dialect, coltype): # we apply a connection output handler that # returns Decimal for positive precision + scale NUMBER # types if dialect.supports_native_decimal: if self.asdecimal and self.scale is None: processors.to_decimal_processor_factory(Decimal) elif not self.asdecimal and self.scale > 0: return processors.to_float else: return None else: # cx_oracle 4 behavior, will assume # floats return super(_OracleNumeric, self).\ result_processor(dialect, coltype)
def bind_processor(self, dialect): if self.scale == 0: return None elif self.asdecimal: processor = processors.to_decimal_processor_factory( decimal.Decimal, self._effective_decimal_return_scale) def process(value): if isinstance(value, (int, float)): return processor(value) else: return value return process else: return processors.to_float
def bind_processor(self, dialect): if self.scale == 0: return None elif self.asdecimal: processor = processors.to_decimal_processor_factory( decimal.Decimal, self._effective_decimal_return_scale) def process(value): if isinstance(value, (int, float)): return processor(value) else: return value return process else: return processors.to_float
def result_processor(self, dialect, coltype): if self.asdecimal: if coltype in (700, 701): return processors.to_decimal_processor_factory(decimal.Decimal) elif coltype == 1700: # pg8000 returns Decimal natively for 1700 return None else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) else: if coltype in (700, 701): # pg8000 returns float natively for 701 return None elif coltype == 1700: return processors.to_float else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype)
def result_processor(self, dialect, coltype): if self.asdecimal: if coltype in _FLOAT_TYPES: return processors.to_decimal_processor_factory(decimal.Decimal) elif coltype in _DECIMAL_TYPES: # pg8000 returns Decimal natively for 1700 return None else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype) else: if coltype in _FLOAT_TYPES: # pg8000 returns float natively for 701 return None elif coltype in _DECIMAL_TYPES: return processors.to_float else: raise exc.InvalidRequestError("Unknown PG numeric type: %d" % coltype)
def result_processor(self, dialect, coltype): if self.asdecimal: if coltype in _FLOAT_TYPES: return processors.to_decimal_processor_factory( decimal.Decimal, self._effective_decimal_return_scale) elif coltype in _DECIMAL_TYPES or coltype in _INT_TYPES: # pg8000 returns Decimal natively for 1700 return None else: raise exc.InvalidRequestError( "Unknown PG numeric type: %d" % coltype) else: if coltype in _FLOAT_TYPES: # pg8000 returns float natively for 701 return None elif coltype in _DECIMAL_TYPES or coltype in _INT_TYPES: return processors.to_float else: raise exc.InvalidRequestError( "Unknown PG numeric type: %d" % coltype)
def result_processor(self, dialect, coltype): if not isinstance(coltype, int): coltype = coltype.oid if self.asdecimal: if coltype in _FLOAT_TYPES: return processors.to_decimal_processor_factory( decimal.Decimal, self._effective_decimal_return_scale) elif coltype in _DECIMAL_TYPES or coltype in _INT_TYPES: # PyGreSQL returns Decimal natively for 1700 (numeric) return None else: raise exc.InvalidRequestError( "Unknown PG numeric type: %d" % coltype) else: if coltype in _FLOAT_TYPES: # PyGreSQL returns float natively for 701 (float8) return None elif coltype in _DECIMAL_TYPES or coltype in _INT_TYPES: return processors.to_float else: raise exc.InvalidRequestError( "Unknown PG numeric type: %d" % coltype)
def go(): to_decimal_processor_factory(decimal.Decimal, 10)(1.2)
def go(): to_decimal_processor_factory({}, 10)
def go(): to_decimal_processor_factory(decimal.Decimal, 10)(1.2)
def go(): to_decimal_processor_factory({}, 10)
def go(): to_decimal_processor_factory(_python_Decimal, 10)(1.2)
def go(): to_decimal_processor_factory(_python_Decimal, 10)(1.2)