From: asimfarooq5 Date: Wed, 14 Dec 2022 20:32:47 +0000 (-0500) Subject: Add MACCADDR8 for PGCompiler X-Git-Tag: rel_1_4_46~16 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=074c1471958e155e79a3392ec65dc629012119c5;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git Add MACCADDR8 for PGCompiler Add MACCADDR8 for PGCompiler Closes: #8393 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/8393 Pull-request-sha: 837a68eba3e31e0acbb7c47ee87bca4e9def7648 Change-Id: I87e4999eb8d82662ff8ab409c98dc57edd7fd271 (cherry picked from commit 33f15740a0b72bae64fc2c2f6d0f9724cfe9164a) --- diff --git a/doc/build/changelog/changelog_14.rst b/doc/build/changelog/changelog_14.rst index 6ca71530aa..ef40bcc370 100644 --- a/doc/build/changelog/changelog_14.rst +++ b/doc/build/changelog/changelog_14.rst @@ -719,7 +719,7 @@ This document details individual issue-level changes made throughout :tickets: 8196 Fixed a crash of the mypy plugin when using a lambda as a Column - default. Pull request curtesy of tchapi. + default. Pull request courtesy of tchapi. .. change:: diff --git a/doc/build/changelog/unreleased_14/8393.rst b/doc/build/changelog/unreleased_14/8393.rst new file mode 100644 index 0000000000..fab9eb04c7 --- /dev/null +++ b/doc/build/changelog/unreleased_14/8393.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: usecase, postgresql + :tickets: 8393 + :versions: 2.0.0b5 + + Added the PostgreSQL type ``MACADDR8``. + Pull request courtesy of Asim Farooq. diff --git a/doc/build/dialects/postgresql.rst b/doc/build/dialects/postgresql.rst index 4e8fb98d95..c591ab0006 100644 --- a/doc/build/dialects/postgresql.rst +++ b/doc/build/dialects/postgresql.rst @@ -31,6 +31,7 @@ they originate from :mod:`sqlalchemy.types` or from the local dialect:: JSON, JSONB, MACADDR, + MACADDR8, MONEY, NUMERIC, OID, @@ -110,6 +111,8 @@ construction arguments, are as follows: .. autoclass:: MACADDR +.. autoclass:: MACADDR8 + .. autoclass:: MONEY .. autoclass:: OID diff --git a/lib/sqlalchemy/dialects/postgresql/__init__.py b/lib/sqlalchemy/dialects/postgresql/__init__.py index 12d9e94443..262e160d8d 100644 --- a/lib/sqlalchemy/dialects/postgresql/__init__.py +++ b/lib/sqlalchemy/dialects/postgresql/__init__.py @@ -30,6 +30,7 @@ from .base import INET from .base import INTEGER from .base import INTERVAL from .base import MACADDR +from .base import MACADDR8 from .base import MONEY from .base import NUMERIC from .base import OID @@ -80,6 +81,7 @@ __all__ = ( "UUID", "BIT", "MACADDR", + "MACADDR8", "MONEY", "OID", "REGCLASS", diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py index 9ad8379e26..aceec887e1 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1679,6 +1679,13 @@ class MACADDR(sqltypes.TypeEngine): PGMacAddr = MACADDR +class MACADDR8(sqltypes.TypeEngine): + __visit_name__ = "MACADDR8" + + +PGMacAddr8 = MACADDR8 + + class MONEY(sqltypes.TypeEngine): r"""Provide the PostgreSQL MONEY type. @@ -2232,6 +2239,7 @@ colspecs = { sqltypes.JSON: _json.JSON, } + ischema_names = { "_array": _array.ARRAY, "hstore": _hstore.HSTORE, @@ -2260,6 +2268,7 @@ ischema_names = { "bit": BIT, "bit varying": BIT, "macaddr": MACADDR, + "macaddr8": MACADDR8, "money": MONEY, "oid": OID, "regclass": REGCLASS, @@ -3007,6 +3016,9 @@ class PGTypeCompiler(compiler.GenericTypeCompiler): def visit_MACADDR(self, type_, **kw): return "MACADDR" + def visit_MACADDR8(self, type_, **kw): + return "MACADDR8" + def visit_MONEY(self, type_, **kw): return "MONEY" diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index 564554f668..1a5cdb6474 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -2719,6 +2719,7 @@ class SpecialTypesTest(fixtures.TablesTest, ComparesTables): Column("bitstring", postgresql.BIT(4)), Column("addr", postgresql.INET), Column("addr2", postgresql.MACADDR), + Column("addr4", postgresql.MACADDR8), Column("price", postgresql.MONEY), Column("addr3", postgresql.CIDR), Column("doubleprec", postgresql.DOUBLE_PRECISION),