diff options
author | Jason Kirtland <jek@discorporate.us> | 2007-07-12 22:18:55 +0000 |
---|---|---|
committer | Jason Kirtland <jek@discorporate.us> | 2007-07-12 22:18:55 +0000 |
commit | 94d81c84cefee51485c26d79b028aa85e61b147c (patch) | |
tree | e161b2f99348fc1f192a01885e9dcb5b58bf95bd /lib/sqlalchemy/databases/mysql.py | |
parent | d115a8c94e5bdbc6675e0d8bb14269beedcdc9ae (diff) | |
download | sqlalchemy-94d81c84cefee51485c26d79b028aa85e61b147c.tar.gz |
- Keep reflected strings in the connection encoding, not unicode. For now.
Diffstat (limited to 'lib/sqlalchemy/databases/mysql.py')
-rw-r--r-- | lib/sqlalchemy/databases/mysql.py | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/lib/sqlalchemy/databases/mysql.py b/lib/sqlalchemy/databases/mysql.py index 2fd6e48d0..92f7cf0a7 100644 --- a/lib/sqlalchemy/databases/mysql.py +++ b/lib/sqlalchemy/databases/mysql.py @@ -1090,7 +1090,7 @@ class MySQLDialect(ansisql.ANSIDialect): for row in _compat_fetch(rp, charset=decode_from): (name, type, nullable, primary_key, default) = \ - (row[0], str(row[1]), row[2] == 'YES', row[3] == 'PRI', row[4]) + (row[0], row[1], row[2] == 'YES', row[3] == 'PRI', row[4]) match = re.match(r'(\w+)(\(.*?\))?\s*(\w+)?\s*(\w+)?', type) col_type = match.group(1) @@ -1118,11 +1118,8 @@ class MySQLDialect(ansisql.ANSIDialect): colargs= [] if default: if col_type == 'timestamp' and default == 'CURRENT_TIMESTAMP': - arg = sql.text(default) - else: - # leave defaults in the connection charset - arg = default.encode(decode_from) - colargs.append(schema.PassiveDefault(arg)) + default = sql.text(default) + colargs.append(schema.PassiveDefault(default)) table.append_column(schema.Column(name, coltype, *colargs, **dict(primary_key=primary_key, nullable=nullable, @@ -1204,16 +1201,16 @@ class _MySQLPythonRowProxy(object): item = self.rowproxy[index] if isinstance(item, array): item = item.tostring() - if self.charset and isinstance(item, str): - return item.decode(self.charset) + if self.charset and isinstance(item, unicode): + return item.encode(self.charset) else: return item def __getattr__(self, attr): item = getattr(self.rowproxy, attr) if isinstance(item, array): item = item.tostring() - if self.charset and isinstance(item, str): - return item.decode(self.charset) + if self.charset and isinstance(item, unicode): + return item.encode(self.charset) else: return item |