On Feb 6, 2013, at 3:52 PM, jank wrote:
> While implementing a custom DB dialect I found an asymmetry in the
> implementation of Engine.table_names() and Engine.has_table(). I do not
> understand if this is intended or can be considered a bug.
>
> In the implementation of table_names() the optional parameter schema is
> checked for None and if None is replaced by self.dialect.default_schema_name.
>
> This is not the case in the implementation of has_table().
>
> In some DBs tables with the same name can exist in different schemas. Given
> the current Engine Implementation situations seem possible where:
>
> engine.has_table('foo') != 'foo' ni engine.table_names()
>
> if the dialect comes with a default_schema_name, table_names() is called
> without schema, and the table 'foo' exists in the non-default schema.
>
> Is this intended behavior?
Not sure where you're referring to, as this decision is dialect-specific. I
can only find one dialect with schema support that perhaps isn't doing this
correctly:
Postgresql, uses default schema via the current_schema() (synonymous with how
default_schema is determined):
http://hg.sqlalchemy.org/sqlalchemy/file/7bcf4e41df26/lib/sqlalchemy/dialects/postgresql/base.py#l1418
SQL Server, uses default schema via a decorator that deals with "owner" and
"schema" simultaneously, ultimately from default_schema_name:
http://hg.sqlalchemy.org/sqlalchemy/file/7bcf4e41df26/lib/sqlalchemy/dialects/mssql/base.py#l1164
Oracle, uses default_schema_name:
http://hg.sqlalchemy.org/sqlalchemy/file/7bcf4e41df26/lib/sqlalchemy/dialects/oracle/base.py#l741
So based on elimination, I gather we're talking about MySQL? It's using
"DESCRIBE" and appears render a given schema name, but if not present doesn't
use default_schema_name. If MySQL DESCRIBE goes across schemas when the schema
name isn't specified, then yes that's a bug, I'd merge a short patch to repair
this.
http://hg.sqlalchemy.org/sqlalchemy/file/7bcf4e41df26/lib/sqlalchemy/dialects/mysql/base.py#l2024
--
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.