Skip to content

Commit d11afed

Browse files
committed
WL14215: Deprecated error codes (v3)
1 parent c631eeb commit d11afed

File tree

5 files changed

+519
-4
lines changed

5 files changed

+519
-4
lines changed

lib/mysql/connector/constants.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@
2929
"""Various MySQL constants and character sets
3030
"""
3131

32+
import six
3233
import ssl
34+
import warnings
3335

3436
from .errors import ProgrammingError
3537
from .charsets import MYSQL_CHARACTER_SETS
@@ -97,6 +99,12 @@ def flag_is_set(flag, flags):
9799
return False
98100

99101

102+
def _obsolete_option(name, new_name, value):
103+
warnings.warn('The option "{}" has been deprecated, use "{}" instead.'
104+
''.format(name, new_name), category=DeprecationWarning)
105+
return value
106+
107+
100108
class _Constants(object):
101109
"""
102110
Base class for constants
@@ -532,7 +540,14 @@ class ServerFlag(_Flags):
532540
}
533541

534542

535-
class RefreshOption(_Constants):
543+
class RefreshOption_meta(type):
544+
@property
545+
def SLAVE(self):
546+
return _obsolete_option("RefreshOption.SLAVE", "RefreshOption.REPLICA",
547+
RefreshOption.REPLICA)
548+
549+
550+
class RefreshOption(six.with_metaclass(RefreshOption_meta, _Constants)):
536551
"""MySQL Refresh command options
537552
538553
Options used when sending the COM_REFRESH server command.
@@ -550,10 +565,11 @@ class RefreshOption(_Constants):
550565
'GRANT': (1 << 0, 'Refresh grant tables'),
551566
'LOG': (1 << 1, 'Start on new log file'),
552567
'TABLES': (1 << 2, 'close all tables'),
553-
'HOSTS': (1 << 3, 'Flush host cache'),
568+
'HOST': (1 << 3, 'Flush host cache'),
554569
'STATUS': (1 << 4, 'Flush status variables'),
555570
'THREADS': (1 << 5, 'Flush thread cache'),
556571
'REPLICA': (1 << 6, 'Reset source info and restart replica thread'),
572+
'SLAVE': (1 << 6, 'Deprecated option; use REPLICA instead.'),
557573
}
558574

559575

0 commit comments

Comments
 (0)