summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2016-01-08 22:01:52 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2016-01-08 22:10:42 -0500
commit1c9252b3a4f1e232e887a7a8bf21b29d449e3776 (patch)
tree8f3a3a92462c1bacb197a78da3a553cb04a9f351
parent7302f06596e0f14e3567788785fc16ecd3cdd9a8 (diff)
downloadsqlalchemy-ticket_2685.tar.gz
- inline get_effective_schema and preparer setup to get profilesticket_2685
back down
-rw-r--r--lib/sqlalchemy/dialects/postgresql/base.py7
-rw-r--r--lib/sqlalchemy/sql/compiler.py32
-rw-r--r--lib/sqlalchemy/testing/assertsql.py6
3 files changed, 28 insertions, 17 deletions
diff --git a/lib/sqlalchemy/dialects/postgresql/base.py b/lib/sqlalchemy/dialects/postgresql/base.py
index fdd5458b3..3b3d65155 100644
--- a/lib/sqlalchemy/dialects/postgresql/base.py
+++ b/lib/sqlalchemy/dialects/postgresql/base.py
@@ -1578,8 +1578,11 @@ class PGExecutionContext(default.DefaultExecutionContext):
name = "%s_%s_seq" % (tab, col)
column._postgresql_seq_name = seq_name = name
- effective_schema = self.connection._get_effective_schema(
- column.table.schema)
+ if column.table is not None:
+ effective_schema = self.connection._get_effective_schema(
+ column.table)
+ else:
+ effective_schema = None
if effective_schema is not None:
exc = "select nextval('\"%s\".\"%s\"')" % \
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index f920dc28a..4068d18be 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -191,7 +191,11 @@ class Compiled(object):
self.dialect = dialect
self.bind = bind
- self.schema_translate_map = schema_translate_map
+ self.preparer = self.dialect.identifier_preparer
+ if schema_translate_map:
+ self.preparer = self.preparer._with_schema_translate(
+ schema_translate_map)
+
if statement is not None:
self.statement = statement
self.can_execute = statement.supports_execution
@@ -204,14 +208,6 @@ class Compiled(object):
"""
pass
- @util.memoized_property
- def preparer(self):
- preparer = self.dialect.identifier_preparer
- if self.schema_translate_map:
- preparer = preparer._with_schema_translate(
- self.schema_translate_map)
- return preparer
-
def _execute_on_connection(self, connection, multiparams, params):
return connection._execute_compiled(self, multiparams, params)
@@ -665,11 +661,16 @@ class SQLCompiler(Compiled):
if table is None or not include_table or not table.named_with_column:
return name
else:
- effective_schema = self.preparer._get_effective_schema(table)
+
+ # inlining of preparer._get_effective_schema
+ effective_schema = table.schema
+ if self.preparer.schema_translate_map:
+ effective_schema = self.preparer.schema_translate_map.get(
+ effective_schema, effective_schema)
if effective_schema:
- schema_prefix = self.preparer.quote_schema(effective_schema) + \
- '.'
+ schema_prefix = self.preparer.quote_schema(
+ effective_schema) + '.'
else:
schema_prefix = ''
tablename = table.name
@@ -1829,7 +1830,12 @@ class SQLCompiler(Compiled):
def visit_table(self, table, asfrom=False, iscrud=False, ashint=False,
fromhints=None, use_schema=True, **kwargs):
if asfrom or ashint:
- effective_schema = self.preparer._get_effective_schema(table)
+
+ # inlining of preparer._get_effective_schema
+ effective_schema = table.schema
+ if self.preparer.schema_translate_map:
+ effective_schema = self.preparer.schema_translate_map.get(
+ effective_schema, effective_schema)
if use_schema and effective_schema:
ret = self.preparer.quote_schema(effective_schema) + \
diff --git a/lib/sqlalchemy/testing/assertsql.py b/lib/sqlalchemy/testing/assertsql.py
index ade99b700..904149c16 100644
--- a/lib/sqlalchemy/testing/assertsql.py
+++ b/lib/sqlalchemy/testing/assertsql.py
@@ -89,14 +89,16 @@ class CompiledSQL(SQLMatchRule):
compiled = \
context.compiled.statement.compile(
dialect=compare_dialect,
- schema_translate_map=context.compiled.schema_translate_map)
+ schema_translate_map=context.
+ compiled.preparer.schema_translate_map)
else:
compiled = (
context.compiled.statement.compile(
dialect=compare_dialect,
column_keys=context.compiled.column_keys,
inline=context.compiled.inline,
- schema_translate_map=context.compiled.schema_translate_map)
+ schema_translate_map=context.
+ compiled.preparer.schema_translate_map)
)
_received_statement = re.sub(r'[\n\t]', '', util.text_type(compiled))
parameters = execute_observed.parameters