we're looking into this now, but I would note that we have a lot of
unit tests which successfully reflect tables with all kinds of
combinations of "schema" being present and non-present, particularly
with Postgres. Its very likely this issue is local to reflecting
tables within the Oracle module.
Let's start at the beginning. There is absolutely no point in
having an "owner" attribute on Table from a SQLAlchemy perspective.
We have a "schema" attribute which already serves as our generic
"namespace of tables" qualifier. The "schema" attribute also forms
part of the Table's identifier within the MetaData object, whereas the
"owner" attribute does not - this makes the "owner" attribute ever
more useless, since no matter how well we set the correct "owner"
attribute on tables and foreign key specifications, it will not help
us to locate the table within the MetaData object which is the whole
point of ForeignKey.
So the arguments that have been made about things like
"owner.schema.tablename" don't really apply to oracle; heres an
authoritative article: http://www.dba-oracle.com/t_schema_components_owner_user.htm
. As far as MS-SQL, thats some other issue which should be
addressed specific to MS-SQL.
I've made changes to oracle's reflection as of r4328. "owner" is now
deprecated and is synomous with "schema". The example you are
working with should work out of the box now with this revision - if
not, please provide some sample tables and the reflection code used,
as well as the use case which fails (like, generating a join or
similar). The big dump of internal dicts is not very helpful since
it's hard to read and does not clearly express what's actually broken.
Also, we had a lot of weirdness involving searching for synonyms,
DBLINK names and such; that idea is still present but has been greatly
scaled back. First of all, its all off by default. To search for
synonyms that match your Table, the Table must have a new flag
"oracle_resolve_synonyms=True" specified. The behavior is disabled by
default since it is now "stickier" - if a related table is found via
ForeignKey, it will attempt to resolve a synonym for that table as
well so that a synonym-configured database reflects consistently.
There was also some logic whereby it was searching for synonyms,
locating a DBLINK, and then jumping to the synonym table over on that
DBLINK. I didn't understand how this code was supposed to work and it
all seemed rather specious to me, since if you've located some synonym
three DBLINK jumps away, it doesn't seem like SQLAlchemy could
effectively use such a table since we don't append explicit DBLINK
qualifiers to tables. So if that breaks something for anyone, let me
know (since I can see what that whole thing was meant to be used for,
if anything).
- mike
thats current defined behavior; the "schema" is used only when a table
is evaulated in a FROM context, not in a "column qualification"
context. its easy enough to change but I'd want to ensure that no
current databases break when all columns are qualified with schema +
tablename.
do you actually have a case where identical tablenames from different
schemas are conflicting ?
>
> Great, I was just wondering. But glad to see confirmation. Yes we do
> have a use case when the same tablenames cause weird behavior in
> ORACLE. Below is a message from our DBA in response to hick-up when we
> occasionally got:
> "ORA-00942: table or view does not exist" error.
so...is an issue, yes ?