summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/sql/compiler.py
diff options
context:
space:
mode:
authormike bayer <mike_mp@zzzcomputing.com>2019-11-09 16:21:55 +0000
committerGerrit Code Review <gerrit@bbpush.zzzcomputing.com>2019-11-09 16:21:55 +0000
commited2c5f9ad1f92010e447797576ab4eef3beee21f (patch)
tree6e39e7366de4ac2fbb6a98e4e5938e33f34422a4 /lib/sqlalchemy/sql/compiler.py
parent4a2dd4902a1168234f14bdd0634728086d53c406 (diff)
parent3a0e0531c179e598c345e5be24e350c375ce7e22 (diff)
downloadsqlalchemy-ed2c5f9ad1f92010e447797576ab4eef3beee21f.tar.gz
Merge "Support for generated columns"
Diffstat (limited to 'lib/sqlalchemy/sql/compiler.py')
-rw-r--r--lib/sqlalchemy/sql/compiler.py13
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):