--- /dev/null
+.. change::
+ :tags: usecase, mariadb
+ :ticket: 10720
+
+ Added sql types ``INET4`` and ``INET6`` in the MariaDB dialect.
YEAR,
)
-Types which are specific to MySQL, or have MySQL-specific
+In addition to the above types, MariaDB also supports the following::
+
+ from sqlalchemy.dialects.mysql import (
+ INET4,
+ INET6,
+ )
+
+Types which are specific to MySQL or MariaDB, or have specific
construction arguments, are as follows:
.. note: where :noindex: is used, indicates a type that is not redefined
:members: __init__
+.. autoclass:: INET4
+
+.. autoclass:: INET6
+
.. autoclass:: INTEGER
:members: __init__
from .dml import Insert
from .dml import insert
from .expression import match
-from ...util import compat
+from .mariadb import INET4
+from .mariadb import INET6
# default dialect
base.dialect = dialect = mysqldb.dialect
"DOUBLE",
"ENUM",
"FLOAT",
+ "INET4",
+ "INET6",
"INTEGER",
"INTEGER",
"JSON",
# mypy: ignore-errors
from .base import MariaDBIdentifierPreparer
from .base import MySQLDialect
+from .base import MySQLTypeCompiler
+from ...sql import sqltypes
+
+
+class INET4(sqltypes.TypeEngine[str]):
+ """INET4 column type for MariaDB
+
+ .. versionadded:: 2.0.37
+ """
+
+ __visit_name__ = "INET4"
+
+
+class INET6(sqltypes.TypeEngine[str]):
+ """INET6 column type for MariaDB
+
+ .. versionadded:: 2.0.37
+ """
+
+ __visit_name__ = "INET6"
+
+
+class MariaDBTypeCompiler(MySQLTypeCompiler):
+ def visit_INET4(self, type_, **kwargs) -> str:
+ return "INET4"
+
+ def visit_INET6(self, type_, **kwargs) -> str:
+ return "INET6"
class MariaDBDialect(MySQLDialect):
supports_statement_cache = True
name = "mariadb"
preparer = MariaDBIdentifierPreparer
+ type_compiler_cls = MariaDBTypeCompiler
def loader(driver):
from sqlalchemy import types as sqltypes
from sqlalchemy import UnicodeText
from sqlalchemy.dialects.mysql import base as mysql
+from sqlalchemy.dialects.mysql import mariadb
from sqlalchemy.testing import assert_raises
from sqlalchemy.testing import assert_raises_message
from sqlalchemy.testing import AssertsCompiledSQL
self.assert_compile(type_, sql_text)
+class INETMariadbTest(fixtures.TestBase, AssertsCompiledSQL):
+ __dialect__ = mariadb.MariaDBDialect()
+
+ @testing.combinations(
+ (mariadb.INET4(), "INET4"),
+ (mariadb.INET6(), "INET6"),
+ )
+ def test_mariadb_inet6(self, type_, res):
+ self.assert_compile(type_, res)
+
+
class TypeRoundTripTest(fixtures.TestBase, AssertsExecutionResults):
__dialect__ = mysql.dialect()
__only_on__ = "mysql", "mariadb"