8000 BUG#27489972: Several COM_% commands have been deprecated · dveeden/mysql-connector-python@426d7ce · GitHub
[go: up one dir, main page]

Skip to content

Commit 426d7ce

Browse files
committed
BUG#27489972: Several COM_% commands have been deprecated
Several COM_% commands have been deprecated in MySQL server. A DeprecationWarning is now raised if any of these commands are used. - COM_FIELD_LIST - COM_REFRESH - COM_SHUTDOWN - COM_PROCESS_INFO - COM_PROCESS_KILL Change-Id: I0aa5af0d85705e183a783a803e75bdc34d6ee8b1
1 parent dc3f682 commit 426d7ce

File tree

2 files changed

+34
-3
lines changed

2 files changed

+34
-3
lines changed

CHANGES.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ v8.0.33
1414
- WL#15435: Improve the logging system
1515
- WL#15401: Support for type hints in module mysqlx
1616
- BUG#30103652: Connector/Python ClientFlag SESION_TRACK is a misspelling
17+
- BUG#27489972: Several COM_% commands have been deprecated
1718
- BUG#27359063: Support for dictionary, named_tuple, and raw to prepared statements cursor
1819

1920
v8.0.32

lib/mysql/connector/constants.py

Lines changed: 33 additions & 3 deletions
126
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
import warnings
3232

3333
from abc import ABC, ABCMeta
34-
from typing import Dict, List, Optional, Sequence, Tuple, Union, ValuesView
34+
from typing import Any, Dict, List, Optional, Sequence, Tuple, Union, ValuesView
3535

3636
from .charsets import MYSQL_CHARACTER_SETS, MYSQL_CHARACTER_SETS_57
3737
from .errors import ProgrammingError
@@ -112,8 +112,18 @@ def flag_is_set(flag: int, flags: int) -> bool:
112112

113113

114114
def _obsolete_option(name: str, new_name: str, value: int) -> int:
115+
"""Raise a deprecation warning and advise a new option name.
116+
117+
Args:
118+
name (str): The name of the option.
119+
new_name (str): The new option name.
120+
value (int): The value of the option.
121+
122+
Returns:
123+
int: The value of the option.
124+
"""
115125
warnings.warn(
116-
f'The option "{name}" has been deprecated, use "{new_name}" instead.',
+
f"The option '{name}' has been deprecated, use '{new_name}' instead.",
117127
category=DeprecationWarning,
118128
)
119129
return value
@@ -339,7 +349,27 @@ class FieldFlag(_Flags):
339349
}
340350

341351

342-
class ServerCmd(_Constants):
352+
class ServerCmdMeta(ABCMeta):
353+
"""ClientFlag Metaclass."""
354+
355+
def __getattribute__(cls, name: str) -> Any:
356+
deprecated_options = (
357+
"FIELD_LIST",
358+
"REFRESH",
359+
"SHUTDOWN",
360+
"PROCESS_INFO",
361+
"PROCESS_KILL",
362+
)
363+
if name in deprecated_options:
364+
warnings.warn(
365+
f"The option 'ServerCmd.{name}' is deprecated and will be removed in "
366+
"a future release.",
367+
category=DeprecationWarning,
368+
)
369+
return super().__getattribute__(name)
370+
371+
372+
class ServerCmd(_Constants, metaclass=ServerCmdMeta):
343373
"""MySQL Server Commands"""
344374

345375
_prefix: str = "COM_"

0 commit comments

Comments
 (0)
0