diff options
author | Lele Gaifax <lele@metapensiero.it> | 2022-11-27 11:28:51 -0500 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2022-11-29 17:11:38 -0500 |
commit | 0b239579f03c82f7669d77c238e4fda8638fb9c3 (patch) | |
tree | ebe836c6d9f60362c4824843478122c7f725c2bd /lib/sqlalchemy/sql | |
parent | 61443aa62bbef158274ae393db399fec7f054c2d (diff) | |
download | sqlalchemy-0b239579f03c82f7669d77c238e4fda8638fb9c3.tar.gz |
Add value-level hooks for SQL type detection; apply to Range
Added additional type-detection for the new PostgreSQL
:class:`_postgresql.Range` type, where previous cases that allowed the
psycopg2-native range objects to be received directly by the DBAPI without
SQLAlchemy intercepting them stopped working, as we now have our own value
object. The :class:`_postgresql.Range` object has been enhanced such that
SQLAlchemy Core detects it in otherwise ambiguous situations (such as
comparison to dates) and applies appropriate bind handlers. Pull request
courtesy Lele Gaifax.
Fixes: #8884
Closes: #8886
Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8886
Pull-request-sha: 6e95e08a30597d3735ab38f2f1a2ccabd968852c
Change-Id: I3ca277c826dcf4b5644f44eb251345b439a84ee4
Diffstat (limited to 'lib/sqlalchemy/sql')
-rw-r--r-- | lib/sqlalchemy/sql/sqltypes.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/sqltypes.py b/lib/sqlalchemy/sql/sqltypes.py index 624b7d16e..308c233e4 100644 --- a/lib/sqlalchemy/sql/sqltypes.py +++ b/lib/sqlalchemy/sql/sqltypes.py @@ -3682,6 +3682,10 @@ _type_map_get = _type_map.get def _resolve_value_to_type(value: Any) -> TypeEngine[Any]: _result_type = _type_map_get(type(value), False) + + if _result_type is False: + _result_type = getattr(value, "__sa_type_engine__", False) + if _result_type is False: # use inspect() to detect SQLAlchemy built-in # objects. |