diff options
Diffstat (limited to 'lib/sqlalchemy')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 76e2ca260..71d12b6be 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -418,8 +418,9 @@ class DefaultCompiler(engine.Compiled): return bind_name def _truncated_identifier(self, ident_class, name): - if (ident_class, name) in self.generated_ids: - return self.generated_ids[(ident_class, name)] + key = ident_class + "|" + name + if key in self.generated_ids: + return self.generated_ids[key] anonname = ANONYMOUS_LABEL.sub(self._process_anon, name) @@ -429,18 +430,19 @@ class DefaultCompiler(engine.Compiled): self.generated_ids[ident_class] = counter + 1 else: truncname = anonname - self.generated_ids[(ident_class, name)] = truncname + self.generated_ids[key] = truncname return truncname def _process_anon(self, match): (ident, derived) = match.group(1,2) - key = ('anonymous', ident) + key = 'anonymous|' + ident if key in self.generated_ids: return self.generated_ids[key] else: - anonymous_counter = self.generated_ids.get(('anon_counter', derived), 1) + counter_key = "anon_counter|" + derived + anonymous_counter = self.generated_ids.get(counter_key, 1) newname = derived + "_" + str(anonymous_counter) - self.generated_ids[('anon_counter', derived)] = anonymous_counter + 1 + self.generated_ids[counter_key] = anonymous_counter + 1 self.generated_ids[key] = newname return newname |