From: Mike Bayer Date: Sat, 17 Dec 2022 16:10:02 +0000 (-0500) Subject: fix changelog for types, add date rendering to whatsnew X-Git-Tag: rel_2_0_0rc1~22 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=161ec7c34aae9821ef67da26b4bf0eb65df9eace;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git fix changelog for types, add date rendering to whatsnew this change is likely somehting people want to see so make it more prominent, also there's no "types" category in changelog so these should be "sql". Change-Id: I9104c210448f3ba0304f1e09d0613240fe8dcf4e References: #8998 --- diff --git a/doc/build/changelog/changelog_20.rst b/doc/build/changelog/changelog_20.rst index 5b3e83750f..11220ba429 100644 --- a/doc/build/changelog/changelog_20.rst +++ b/doc/build/changelog/changelog_20.rst @@ -782,7 +782,7 @@ also gains the same capability using native cx_Oracle or OracleDB features. .. change:: - :tags: bug, pool + :tags: bug, engine :tickets: 8523 The :class:`_pool.QueuePool` now ignores ``max_overflow`` when @@ -1295,7 +1295,7 @@ that of psycopg2 or most MySQL dialects. .. change:: - :tags: feature, types + :tags: feature, sql :tickets: 7212 Added new backend-agnostic :class:`_types.Uuid` datatype generalized from @@ -1567,7 +1567,7 @@ accompany the existing ``def visit_concat_op_binary()`` method. .. change:: - :tags: feature, types + :tags: feature, sql :tickets: 5465 Added :class:`.Double`, :class:`.DOUBLE`, :class:`.DOUBLE_PRECISION` @@ -1674,7 +1674,7 @@ :ref:`change_7086` .. change:: - :tags: usecase, datatypes + :tags: usecase, sql :tickets: 5052 Added modified ISO-8601 rendering (i.e. ISO-8601 with the T converted to a @@ -1684,6 +1684,10 @@ Previously this rendering was not implemented for dialect-specific compilation. + .. seealso:: + + :ref:`change_5052` + .. change:: :tags: removed, engine :tickets: 7258 @@ -2018,7 +2022,7 @@ cx_Oracle 7 is now the minimum version for cx_Oracle. .. change:: - :tags: bug, types + :tags: bug, sql :tickets: 7551 Python string values for which a SQL type is determined from the type of diff --git a/doc/build/changelog/unreleased_14/8989.rst b/doc/build/changelog/unreleased_14/8989.rst index 4c38fdf019..2287bec7b4 100644 --- a/doc/build/changelog/unreleased_14/8989.rst +++ b/doc/build/changelog/unreleased_14/8989.rst @@ -1,5 +1,5 @@ .. change:: - :tags: bug, types + :tags: bug, sql :tickets: 8989 :versions: 2.0.0b5 diff --git a/doc/build/changelog/whatsnew_20.rst b/doc/build/changelog/whatsnew_20.rst index d141ea7a07..8c23c24cd9 100644 --- a/doc/build/changelog/whatsnew_20.rst +++ b/doc/build/changelog/whatsnew_20.rst @@ -1546,6 +1546,53 @@ backend:: :ticket:`7631` +.. _change_5052: + +DATE, TIME, DATETIME datatypes now support literal rendering on all backends +----------------------------------------------------------------------------- + +Literal rendering is now implemented for date and time types for backend +specific compilation, including PostgreSQL and Oracle:: + + >>> import datetime + + >>> from sqlalchemy import DATETIME + >>> from sqlalchemy import literal + >>> from sqlalchemy.dialects import oracle + >>> from sqlalchemy.dialects import postgresql + + >>> date_literal = literal(datetime.datetime.now(), DATETIME) + + >>> print( + ... date_literal.compile( + ... dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True} + ... ) + ... ) + '2022-12-17 11:02:13.575789' + + >>> print( + ... date_literal.compile( + ... dialect=oracle.dialect(), compile_kwargs={"literal_binds": True} + ... ) + ... ) + TO_TIMESTAMP('2022-12-17 11:02:13.575789', 'YYYY-MM-DD HH24:MI:SS.FF') + +Previously, such literal rendering only worked when stringifying statements +without any dialect given; when attempting to render with a dialect-specific +type, a ``NotImplementedError`` would be raised, up until +SQLAlchemy 1.4.45 where this became a :class:`.CompileError` (part of +:ticket:`8800`). + +The default rendering is modified ISO-8601 rendering (i.e. ISO-8601 with the T +converted to a space) when using ``literal_binds`` with the SQL compilers +provided by the PostgreSQL, MySQL, MariaDB, MSSQL, Oracle dialects. For Oracle, +the ISO format is wrapped inside of an appropriate TO_DATE() function call. +The rendering for SQLite is unchanged as this dialect always included string +rendering for date values. + + + +:ticket:`5052` .. _change_8710: