Re: [Sqlalchemy-tickets] [sqlalchemy] #2922: allow PG search path reflection behavior to be configu
Brought to you by:
zzzeek
|
From: sqlalchemy <mi...@zz...> - 2014-01-29 14:10:28
|
#2922: allow PG search path reflection behavior to be configurable
------------------------------+-------------------------------
Reporter: vrobin | Owner: zzzeek
Type: defect | Status: new
Priority: high | Milestone: 0.9.2
Component: postgres | Severity: major - 1-3 hours
Resolution: | Keywords:
Progress State: needs tests |
------------------------------+-------------------------------
Comment (by vrobin):
With failing environment (pgsql 9.1 / linux), patch fails to correct the
problem with the real database and application.
Behavior is rather weird to me because the parameter
"postgresql_ignore_search_path" changes during introspection.
This can be seen after adding this trace in dialects/postgresql/base.py
(line 1981):
{{{
@reflection.cache
def get_foreign_keys(self, connection, table_name, schema=None,
postgresql_ignore_search_path=False, **kw):
print "XXXXXY", postgresql_ignore_search_path, table_name, schema
}}}
and calling this:
{{{
metadata = MetaData(bind=engine, schema=SCHEMA)
metadata.bind.echo = True
print sqlalchemy.__version__
print "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
metadata.reflect(postgresql_ignore_search_path=True) ### <= Here
print "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ"
}}}
The result is the following
XXXXXY True table1 mymainschema
XXXXXY True table2 mymainschema
XXXXXY True table3 mymainschema
XXXXXY True table4 mymainschema
XXXXXY False table5 mymainschema
[...]
XXXXXY False tableX mymainschema
Change from True to False, doesn't occur in a table having a dependency in
secondary schema.
If I change default value from
def get_foreign_keys(self, connection, table_name, schema=None,
postgresql_ignore_search_path=False, **kw):
to
def get_foreign_keys(self, connection, table_name, schema=None,
postgresql_ignore_search_path=True, **kw):
Things naturally works.
PS: It is possible that 9222.patch is incomplete because when I manually
patch my sqlalchemy sourcetree, It didn't have
class PGDialect(default.DefaultDialect):
"using": False,
"where": None,
"ops": {}
(that may have been since 0.9.1 release:
http://www.sqlalchemy.org/trac/changeset/1af8e2491dcbed723d2cdafd44fd37f1a6908e91#file5
)
--
Ticket URL: <http://www.sqlalchemy.org/trac/ticket/2922#comment:13>
sqlalchemy <http://www.sqlalchemy.org/>
The Database Toolkit for Python
|