diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-09 14:39:25 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2012-09-09 14:39:25 -0400 |
commit | 1c325dc9c73820e78ab79d4aa160dc0f6cbe3b65 (patch) | |
tree | 02b1a3fb6f24fe0bddd582a3fec519c99d40d36c /lib/sqlalchemy/sql/compiler.py | |
parent | b96250d0063cd7ce9cc1f95abade68e6656d6acb (diff) | |
download | sqlalchemy-1c325dc9c73820e78ab79d4aa160dc0f6cbe3b65.tar.gz |
- [feature] Added a hook to the system of rendering
CREATE TABLE that provides access to the render for each
Column individually, by constructing a @compiles
function against the new schema.CreateColumn
construct. [ticket:2463]
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 3778c7683..8a7f05eb3 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -1728,6 +1728,10 @@ class DDLCompiler(engine.Compiled): def sql_compiler(self): return self.dialect.statement_compiler(self.dialect, None) + @util.memoized_property + def type_compiler(self): + return self.dialect.type_compiler + @property def preparer(self): return self.dialect.identifier_preparer @@ -1776,21 +1780,16 @@ class DDLCompiler(engine.Compiled): # if only one primary key, specify it along with the column first_pk = False - for column in table.columns: + for create_column in create.columns: + column = create_column.element try: text += separator separator = ", \n" - text += "\t" + self.get_column_specification( - column, - first_pk=column.primary_key and \ - not first_pk - ) + text += "\t" + self.process(create_column, + first_pk=column.primary_key + and not first_pk) if column.primary_key: first_pk = True - const = " ".join(self.process(constraint) \ - for constraint in column.constraints) - if const: - text += " " + const except exc.CompileError, ce: # Py3K #raise exc.CompileError("(in table '%s', column '%s'): %s" @@ -1815,6 +1814,20 @@ class DDLCompiler(engine.Compiled): text += "\n)%s\n\n" % self.post_create_table(table) return text + def visit_create_column(self, create, first_pk=False): + column = create.element + + text = self.get_column_specification( + column, + first_pk=first_pk + ) + const = " ".join(self.process(constraint) \ + for constraint in column.constraints) + if const: + text += " " + const + + return text + def create_table_constraints(self, table): # On some DB order is significant: visit PK first, then the |