Skip to content

contraint name for column level constraints #2305

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
sqlalchemy-bot opened this issue Oct 21, 2011 · 2 comments
Closed

contraint name for column level constraints #2305

sqlalchemy-bot opened this issue Oct 21, 2011 · 2 comments
Labels
bug Something isn't working schema things related to the DDL related objects like Table, Column, CreateIndex, etc.
Milestone

Comments

@sqlalchemy-bot
Copy link
Collaborator

Migrated issue, originally created by Michael Bayer (@zzzeek)

need to put this only on those DBs which support it (or override those that don't support it).

So far PG and SQLite seem to support it, MySQL does not:

--- a/lib/sqlalchemy/sql/compiler.py	Thu Oct 20 15:00:17 2011 -0400
+++ b/lib/sqlalchemy/sql/compiler.py	Fri Oct 21 20:07:28 2011 -0400
@@ -1403,7 +1403,11 @@
         return text
 
     def visit_column_check_constraint(self, constraint):
-        text = "CHECK (%s)" % constraint.sqltext
+        text = ""
+        if constraint.name is not None:
+            text += "CONSTRAINT %s " % \
+                        self.preparer.format_constraint(constraint)
+        text += "CHECK (%s)" % constraint.sqltext
         text += self.define_constraint_deferrability(constraint)
         return text
@sqlalchemy-bot
Copy link
Collaborator Author

Michael Bayer (@zzzeek) wrote:

133a0b2

@sqlalchemy-bot
Copy link
Collaborator Author

Changes by Michael Bayer (@zzzeek):

  • changed status to closed

@sqlalchemy-bot sqlalchemy-bot added schema things related to the DDL related objects like Table, Column, CreateIndex, etc. bug Something isn't working labels Nov 27, 2018
@sqlalchemy-bot sqlalchemy-bot added this to the 0.7.4 milestone Nov 27, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working schema things related to the DDL related objects like Table, Column, CreateIndex, etc.
Projects
None yet
Development

No branches or pull requests

1 participant