diff options
| author | mike bayer <mike_mp@zzzcomputing.com> | 2019-11-09 16:21:55 +0000 |
|---|---|---|
| committer | Gerrit Code Review <gerrit@bbpush.zzzcomputing.com> | 2019-11-09 16:21:55 +0000 |
| commit | ed2c5f9ad1f92010e447797576ab4eef3beee21f (patch) | |
| tree | 6e39e7366de4ac2fbb6a98e4e5938e33f34422a4 /lib/sqlalchemy/sql/compiler.py | |
| parent | 4a2dd4902a1168234f14bdd0634728086d53c406 (diff) | |
| parent | 3a0e0531c179e598c345e5be24e350c375ce7e22 (diff) | |
| download | sqlalchemy-ed2c5f9ad1f92010e447797576ab4eef3beee21f.tar.gz | |
Merge "Support for generated columns"
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
| -rw-r--r-- | lib/sqlalchemy/sql/compiler.py | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py index 546fffc6c..85c1750b7 100644 --- a/lib/sqlalchemy/sql/compiler.py +++ b/lib/sqlalchemy/sql/compiler.py @@ -3173,6 +3173,9 @@ class DDLCompiler(Compiled): if default is not None: colspec += " DEFAULT " + default + if column.computed is not None: + colspec += " " + self.process(column.computed) + if not column.nullable: colspec += " NOT NULL" return colspec @@ -3314,6 +3317,16 @@ class DDLCompiler(Compiled): text += " MATCH %s" % constraint.match return text + def visit_computed_column(self, generated): + text = "GENERATED ALWAYS AS (%s)" % self.sql_compiler.process( + generated.sqltext, include_table=False, literal_binds=True + ) + if generated.persisted is True: + text += " STORED" + elif generated.persisted is False: + text += " VIRTUAL" + return text + class GenericTypeCompiler(TypeCompiler): def visit_FLOAT(self, type_, **kw): |
