diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-06-02 19:52:26 -0400 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2011-06-02 19:52:26 -0400 |
| commit | 9211ecb6cfdc8e213a6e8154aaffc6c81da5820f (patch) | |
| tree | c1e54b4e2652d681ebcdf296c087c4925cdf4b80 /lib/sqlalchemy | |
| parent | bf0890c6694bd6464a0821e807d425111c9868c5 (diff) | |
| download | sqlalchemy-9211ecb6cfdc8e213a6e8154aaffc6c81da5820f.tar.gz | |
- Unit tests pass 100% on MySQL installed
on windows, after aggressive exclusion of a wide variety
of tests. Not clear to what degree the failures are related to
version 5.5 vs. the usage of windows, in particular the ON UPDATE CASCADE
immediately crashes the server. The features being tested here are all
edge cases not likely to be used in typical MySQL environments.
- Removed the "adjust casing" step that would
fail when reflecting a table on MySQL
on windows with a mixed case name. After some
experimenting with a windows MySQL server, it's
been determined that this step wasn't really
helping the situation much; MySQL does not return
FK names with proper casing on non-windows
platforms either, and removing the step at
least allows the reflection to act more like
it does on other OSes. A warning here
has been considered but its difficult to
determine under what conditions such a warning
can be raised, so punted on that for now -
added some docs instead. [ticket:2181]
- supports_sane_rowcount will be set to False
if using MySQLdb and the DBAPI doesn't provide
the constants.CLIENT module.
Diffstat (limited to 'lib/sqlalchemy')
| -rw-r--r-- | lib/sqlalchemy/connectors/mysqldb.py | 2 | ||||
| -rw-r--r-- | lib/sqlalchemy/dialects/mysql/base.py | 29 | ||||
| -rw-r--r-- | lib/sqlalchemy/engine/reflection.py | 6 |
3 files changed, 18 insertions, 19 deletions
diff --git a/lib/sqlalchemy/connectors/mysqldb.py b/lib/sqlalchemy/connectors/mysqldb.py index 189c412a0..b5a9f05a8 100644 --- a/lib/sqlalchemy/connectors/mysqldb.py +++ b/lib/sqlalchemy/connectors/mysqldb.py @@ -93,7 +93,7 @@ class MySQLDBConnector(Connector): ).constants.CLIENT client_flag |= CLIENT_FLAGS.FOUND_ROWS except (AttributeError, ImportError): - pass + self.supports_sane_rowcount = False opts['client_flag'] = client_flag return [[], opts] diff --git a/lib/sqlalchemy/dialects/mysql/base.py b/lib/sqlalchemy/dialects/mysql/base.py index 33dc8a73e..bb23c12af 100644 --- a/lib/sqlalchemy/dialects/mysql/base.py +++ b/lib/sqlalchemy/dialects/mysql/base.py @@ -68,6 +68,22 @@ creation option can be specified in this syntax:: mysql_charset='utf8' ) +Case Sensitivity and Table Reflection +------------------------------------- + +MySQL has inconsistent support for case-sensitive identifier +names, basing support on specific details of the underlying +operating system. However, it has been observed that no matter +what case sensitivity behavior is present, the names of tables in +foreign key declarations are *always* received from the database +as all-lower case, making it impossible to accurately reflect a +schema where inter-related tables use mixed-case identifier names. + +Therefore it is strongly advised that table names be declared as +all lower case both within SQLAlchemy as well as on the MySQL +database itself, especially if database reflection features are +to be used. + Keys ---- @@ -1974,17 +1990,6 @@ class MySQLDialect(default.DefaultDialect): sql = parser._describe_to_create(table_name, columns) return parser.parse(sql, charset) - def _adjust_casing(self, table, charset=None): - """Adjust Table name to the server case sensitivity, if needed.""" - - casing = self._server_casing - - # For winxx database hosts. TODO: is this really needed? - if casing == 1 and table.name != table.name.lower(): - table.name = table.name.lower() - lc_alias = sa_schema._get_table_key(table.name, table.schema) - table.metadata.tables[lc_alias] = table - def _detect_charset(self, connection): raise NotImplementedError() @@ -2114,7 +2119,7 @@ class MySQLTableDefinitionParser(object): self.dialect = dialect self.preparer = preparer self._prep_regexes() - + def parse(self, show_create, charset): state = ReflectedState() state.charset = charset diff --git a/lib/sqlalchemy/engine/reflection.py b/lib/sqlalchemy/engine/reflection.py index ca4360325..e87c1ce0f 100644 --- a/lib/sqlalchemy/engine/reflection.py +++ b/lib/sqlalchemy/engine/reflection.py @@ -346,12 +346,6 @@ class Inspector(object): """ dialect = self.bind.dialect - # MySQL dialect does this. Applicable with other dialects? - if hasattr(dialect, '_connection_charset') \ - and hasattr(dialect, '_adjust_casing'): - charset = dialect._connection_charset - dialect._adjust_casing(table) - # table attributes we might need. reflection_options = dict( (k, table.kwargs.get(k)) for k in dialect.reflection_options if k in table.kwargs) |
