Skip to content

Commit 3b7d870

Browse files
committed
Make the charset configurable for mysql
We now have an option to configure the mysql charset used when opening the database. The default is now utf8 for both, python2 and python3. No charset argument is passed if this is configured to 'default'. Previously we were passing 'utf8' for python3 and no charset option for python2 which made regression tests fail depending on the mysql configuration.
1 parent 1df9e1a commit 3b7d870

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

CHANGES.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,6 @@ Fixed:
1919
Meerwald)
2020
- exception in logout action when there is no session (Christof
2121
Meerwald)
22-
- Supply charset argument for connection creation for mysql, even for
23-
python2: The parameter was conditional on python version > 2 but seems to
24-
work fine with python2.7. According to the MySQLdb API docs, the
25-
charset argument is supported with MySQL 4.1 which was released in
26-
2004. (Ralf Schlatterbeck)
2722

2823
Features:
2924

@@ -36,6 +31,13 @@ Features:
3631
Schlatterbeck)
3732
- Add a 'is_restore_ok' method similar to 'is_retire_ok' for use in
3833
templates.
34+
- Allow to configure the mysql charset when opening a connection to the
35+
database. The parameter was conditional on python version > 2 but
36+
seems to work fine with python2.7. According to the MySQLdb API docs,
37+
the charset argument is supported with MySQL 4.1 which was released in
38+
2004. There are some legacy reasons why one would want to not pass a
39+
charset argument or pass an argument different from the default of
40+
'utf8'. (Ralf Schlatterbeck)
3941

4042
2020-04-05 2.0.0 beta 0
4143

roundup/backends/back_mysql.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,9 @@ def connection_dict(config, dbnamestr=None):
5454
del d['password']
5555
if 'port' in d:
5656
d['port'] = int(d['port'])
57-
# This was conditional on python version > 2 but seems to work fine
58-
# with python2.7. According to the MySQLdb API docs, the charset
59-
# argument is supported with MySQL 4.1 which was released in 2004.
60-
d['charset'] = 'utf8'
57+
charset = config.RDBMS_MYSQL_CHARSET
58+
if charset != 'default':
59+
d['charset'] = charset
6160
return d
6261

6362
def db_nuke(config):

roundup/configuration.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,12 @@ def str2value(self, value):
10471047
(NullableOption, 'read_default_group', 'roundup',
10481048
"Name of the group to use in the MySQL defaults file (.my.cnf).\n"
10491049
"Only used in MySQL connections."),
1050+
(Option, 'mysql_charset', 'utf8',
1051+
"Charset to use for mysql connection,\n"
1052+
"use 'default' for the mysql default, no charset option\n"
1053+
"is used when creating the connection in that case.\n"
1054+
"Otherwise any permissible mysql charset is allowed here.\n"
1055+
"Only used in MySQL connections."),
10501056
(IntegerNumberGeqZeroOption, 'sqlite_timeout', '30',
10511057
"Number of seconds to wait when the SQLite database is locked\n"
10521058
"Default: use a 30 second timeout (extraordinarily generous)\n"

0 commit comments

Comments
 (0)