You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Migrated issue, originally created by Michael Bayer (@zzzeek)
from sqlalchemy import *
from sqlalchemy.sql.expression import ColumnClause
class CodenameConstraint(CheckConstraint):
"""Check that the column uses a limited alphabet."""
def __init__(self, column_name):
column = ColumnClause(column_name)
super(CodenameConstraint, self).__init__(
column.op("~")("^[A-Za-z0-9_-]+$"))
m = MetaData()
t = Table(
't', m, Column('x', String, CodenameConstraint('x')),
)
from sqlalchemy.schema import CreateTable
print CreateTable(t)
a string compiler is being invoked separately, needs this:
diff --git a/lib/sqlalchemy/sql/compiler.py b/lib/sqlalchemy/sql/compiler.py
index 4415028..b18f903 100644
--- a/lib/sqlalchemy/sql/compiler.py
+++ b/lib/sqlalchemy/sql/compiler.py
@@ -2602,7 +2602,9 @@ class DDLCompiler(Compiled):
formatted_name = self.preparer.format_constraint(constraint)
if formatted_name is not None:
text += "CONSTRAINT %s " % formatted_name
- text += "CHECK (%s)" % constraint.sqltext
+ text += "CHECK (%s)" % self.sql_compiler.process(constraint.sqltext,
+ include_table=False,
+ literal_binds=True)
text += self.define_constraint_deferrability(constraint)
return text
been this way for years so 1.2 to allow for any surprises.
The text was updated successfully, but these errors were encountered:
Apply SQL compilation to sqltext for column-level CHECK constraint
Fixed bug where a column-level :class:.CheckConstraint would fail
to compile the SQL expression using the underlying dialect compiler
as well as apply proper flags to generate literal values as
inline, in the case that the sqltext is a Core expression and
not just a plain string. This was long-ago fixed for table-level
check constraints in 0.9 as part of 🎫2742, which more commonly
feature Core SQL expressions as opposed to plain string expressions.
Migrated issue, originally created by Michael Bayer (@zzzeek)
a string compiler is being invoked separately, needs this:
been this way for years so 1.2 to allow for any surprises.
The text was updated successfully, but these errors were encountered: