From 6c27bf5048fc7335a1d1fdd49b651b1a164b8e32 Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Wed, 23 May 2018 16:22:48 -0400 Subject: Turn oracle BINARY_DOUBLE, BINARY_FLOAT, DOUBLE_PRECISION into floats The Oracle BINARY_FLOAT and BINARY_DOUBLE datatypes now participate within cx_Oracle.setinputsizes(), passing along NATIVE_FLOAT, so as to support the NaN value. Additionally, :class:`.oracle.BINARY_FLOAT`, :class:`.oracle.BINARY_DOUBLE` and :class:`.oracle.DOUBLE_PRECISION` now subclass :class:`.Float`, since these are floating point datatypes, not decimal. These datatypes were already defaulting the :paramref:`.Float.asdecimal` flag to False in line with what :class:`.Float` already does. Added reflection capabilities for the :class:`.oracle.BINARY_FLOAT`, :class:`.oracle.BINARY_DOUBLE` datatypes. Change-Id: Id99b912e83052654a17d07dc92b4dcb958cb7600 Fixes: #4264 --- lib/sqlalchemy/sql/type_api.py | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lib/sqlalchemy/sql') diff --git a/lib/sqlalchemy/sql/type_api.py b/lib/sqlalchemy/sql/type_api.py index 1d1d6e089..6a323683b 100644 --- a/lib/sqlalchemy/sql/type_api.py +++ b/lib/sqlalchemy/sql/type_api.py @@ -445,6 +445,20 @@ class TypeEngine(Visitable): except KeyError: return self._dialect_info(dialect)['impl'] + def _unwrapped_dialect_impl(self, dialect): + """Return the 'unwrapped' dialect impl for this type. + + For a type that applies wrapping logic (e.g. TypeDecorator), give + us the real, actual dialect-level type that is used. + + This is used by TypeDecorator itself as well at least one case where + dialects need to check that a particular specific dialect-level + type is in use, within the :meth:`.DefaultDialect.set_input_sizes` + method. + + """ + return self.dialect_impl(dialect) + def _cached_literal_processor(self, dialect): """Return a dialect-specific literal processor for this type.""" try: @@ -922,7 +936,7 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): # otherwise adapt the impl type, link # to a copy of this TypeDecorator and return # that. - typedesc = self.load_dialect_impl(dialect).dialect_impl(dialect) + typedesc = self._unwrapped_dialect_impl(dialect) tt = self.copy() if not isinstance(tt, self.__class__): raise AssertionError('Type object %s does not properly ' @@ -989,6 +1003,20 @@ class TypeDecorator(SchemaEventTarget, TypeEngine): """ return self.impl + def _unwrapped_dialect_impl(self, dialect): + """Return the 'unwrapped' dialect impl for this type. + + For a type that applies wrapping logic (e.g. TypeDecorator), give + us the real, actual dialect-level type that is used. + + This is used by TypeDecorator itself as well at least one case where + dialects need to check that a particular specific dialect-level + type is in use, within the :meth:`.DefaultDialect.set_input_sizes` + method. + + """ + return self.load_dialect_impl(dialect).dialect_impl(dialect) + def __getattr__(self, key): """Proxy all other undefined accessors to the underlying implementation.""" -- cgit v1.2.1