From 33f15740a0b72bae64fc2c2f6d0f9724cfe9164a Mon Sep 17 00:00:00 2001 From: asimfarooq5 Date: Wed, 14 Dec 2022 15:32:47 -0500 Subject: [PATCH] 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 --- doc/build/changelog/changelog_14.rst | 2 +- doc/build/changelog/unreleased_20/8393.rst | 6 ++++++ doc/build/dialects/postgresql.rst | 3 +++ lib/sqlalchemy/dialects/postgresql/__init__.py | 2 ++ lib/sqlalchemy/dialects/postgresql/base.py | 7 +++++++ lib/sqlalchemy/dialects/postgresql/types.py | 7 +++++++ test/dialect/postgresql/test_types.py | 1 + 7 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 doc/build/changelog/unreleased_20/8393.rst diff --git a/doc/build/changelog/changelog_14.rst b/doc/build/changelog/changelog_14.rst index 9e279acade..248b2041ca 100644 --- a/doc/build/changelog/changelog_14.rst +++ b/doc/build/changelog/changelog_14.rst @@ -734,7 +734,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_20/8393.rst b/doc/build/changelog/unreleased_20/8393.rst new file mode 100644 index 0000000000..7584ae91d9 --- /dev/null +++ b/doc/build/changelog/unreleased_20/8393.rst @@ -0,0 +1,6 @@ +.. change:: + :tags: usecase, postgresql + :tickets: 8393 + + 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 2f541b5abd..b53a1518a5 100644 --- a/doc/build/dialects/postgresql.rst +++ b/doc/build/dialects/postgresql.rst @@ -323,6 +323,7 @@ they originate from :mod:`sqlalchemy.types` or from the local dialect:: JSON, JSONB, MACADDR, + MACADDR8, MONEY, NUMERIC, OID, @@ -412,6 +413,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 7890541ffd..97d5ac84e1 100644 --- a/lib/sqlalchemy/dialects/postgresql/__init__.py +++ b/lib/sqlalchemy/dialects/postgresql/__init__.py @@ -69,6 +69,7 @@ from .types import CIDR from .types import INET from .types import INTERVAL from .types import MACADDR +from .types import MACADDR8 from .types import MONEY from .types import OID from .types import REGCLASS @@ -99,6 +100,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 f9108094f2..5893a1a914 100644 --- a/lib/sqlalchemy/dialects/postgresql/base.py +++ b/lib/sqlalchemy/dialects/postgresql/base.py @@ -1419,6 +1419,7 @@ from .types import CIDR as CIDR from .types import INET as INET from .types import INTERVAL as INTERVAL from .types import MACADDR as MACADDR +from .types import MACADDR8 as MACADDR8 from .types import MONEY as MONEY from .types import OID as OID from .types import PGBit as PGBit # noqa: F401 @@ -1426,6 +1427,7 @@ from .types import PGCidr as PGCidr # noqa: F401 from .types import PGInet as PGInet # noqa: F401 from .types import PGInterval as PGInterval # noqa: F401 from .types import PGMacAddr as PGMacAddr # noqa: F401 +from .types import PGMacAddr8 as PGMacAddr8 # noqa: F401 from .types import PGUuid as PGUuid from .types import REGCLASS as REGCLASS from .types import TIME as TIME @@ -1583,6 +1585,7 @@ colspecs = { UUID: PGUuid, } + ischema_names = { "_array": _array.ARRAY, "hstore": _hstore.HSTORE, @@ -1617,6 +1620,7 @@ ischema_names = { "bit": BIT, "bit varying": BIT, "macaddr": MACADDR, + "macaddr8": MACADDR8, "money": MONEY, "oid": OID, "regclass": REGCLASS, @@ -2390,6 +2394,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/lib/sqlalchemy/dialects/postgresql/types.py b/lib/sqlalchemy/dialects/postgresql/types.py index 72703ff814..b275deaf92 100644 --- a/lib/sqlalchemy/dialects/postgresql/types.py +++ b/lib/sqlalchemy/dialects/postgresql/types.py @@ -46,6 +46,13 @@ class MACADDR(sqltypes.TypeEngine[str]): PGMacAddr = MACADDR +class MACADDR8(sqltypes.TypeEngine[str]): + __visit_name__ = "MACADDR8" + + +PGMacAddr8 = MACADDR8 + + class MONEY(sqltypes.TypeEngine[str]): r"""Provide the PostgreSQL MONEY type. diff --git a/test/dialect/postgresql/test_types.py b/test/dialect/postgresql/test_types.py index dcde497b46..b8dc0f3c09 100644 --- a/test/dialect/postgresql/test_types.py +++ b/test/dialect/postgresql/test_types.py @@ -3076,6 +3076,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), -- 2.47.2