This commit is contained in:
2025-05-22 20:25:38 +02:00
parent 09f6750c2b
commit ce03fbf12f
529 changed files with 3353 additions and 3312 deletions

View File

@@ -999,14 +999,14 @@ output::
)
""" # noqa
from __future__ import annotations
from array import array as _array
from collections import defaultdict
from itertools import compress
import re
from typing import cast
from sqlalchemy import literal_column
from sqlalchemy.sql import visitors
from . import reflection as _reflection
from .enumerated import ENUM
from .enumerated import SET
@@ -1047,10 +1047,12 @@ from .types import TINYTEXT
from .types import VARCHAR
from .types import YEAR
from ... import exc
from ... import literal_column
from ... import log
from ... import schema as sa_schema
from ... import sql
from ... import util
from ...engine import cursor as _cursor
from ...engine import default
from ...engine import reflection
from ...engine.reflection import ReflectionDefaults
@@ -1062,7 +1064,10 @@ from ...sql import operators
from ...sql import roles
from ...sql import sqltypes
from ...sql import util as sql_util
from ...sql import visitors
from ...sql.compiler import InsertmanyvaluesSentinelOpts
from ...sql.compiler import SQLCompiler
from ...sql.schema import SchemaConst
from ...types import BINARY
from ...types import BLOB
from ...types import BOOLEAN
@@ -1071,6 +1076,7 @@ from ...types import UUID
from ...types import VARBINARY
from ...util import topological
SET_RE = re.compile(
r"\s*SET\s+(?:(?:GLOBAL|SESSION)\s+)?\w", re.I | re.UNICODE
)
@@ -1164,6 +1170,32 @@ ischema_names = {
class MySQLExecutionContext(default.DefaultExecutionContext):
def post_exec(self):
if (
self.isdelete
and cast(SQLCompiler, self.compiled).effective_returning
and not self.cursor.description
):
# All MySQL/mariadb drivers appear to not include
# cursor.description for DELETE..RETURNING with no rows if the
# WHERE criteria is a straight "false" condition such as our EMPTY
# IN condition. manufacture an empty result in this case (issue
# #10505)
#
# taken from cx_Oracle implementation
self.cursor_fetch_strategy = (
_cursor.FullyBufferedCursorFetchStrategy(
self.cursor,
[
(entry.keyname, None)
for entry in cast(
SQLCompiler, self.compiled
)._result_columns
],
[],
)
)
def create_server_side_cursor(self):
if self.dialect.supports_server_side_cursors:
return self._dbapi_connection.cursor(self.dialect._sscursor)
@@ -1208,6 +1240,12 @@ class MySQLCompiler(compiler.SQLCompiler):
)
return f"{clause} WITH ROLLUP"
def visit_aggregate_strings_func(self, fn, **kw):
expr, delimeter = (
elem._compiler_dispatch(self, **kw) for elem in fn.clauses
)
return f"group_concat({expr} SEPARATOR {delimeter})"
def visit_sequence(self, seq, **kw):
return "nextval(%s)" % self.preparer.format_sequence(seq)
@@ -1760,7 +1798,12 @@ class MySQLCompiler(compiler.SQLCompiler):
class MySQLDDLCompiler(compiler.DDLCompiler):
def get_column_specification(self, column, **kw):
"""Builds column DDL."""
if (
self.dialect.is_mariadb is True
and column.computed is not None
and column._user_defined_nullable is SchemaConst.NULL_UNSPECIFIED
):
column.nullable = True
colspec = [
self.preparer.format_column(column),
self.dialect.type_compiler_instance.process(