]> git.ipfire.org Git - thirdparty/sqlalchemy/sqlalchemy.git/commitdiff
add a brief doc for custom DDL
authorMike Bayer <mike_mp@zzzcomputing.com>
Sun, 3 Jan 2010 18:22:50 +0000 (18:22 +0000)
committerMike Bayer <mike_mp@zzzcomputing.com>
Sun, 3 Jan 2010 18:22:50 +0000 (18:22 +0000)
doc/build/metadata.rst
doc/build/reference/ext/compiler.rst

index 078162f4648c37db58e71960e3ac1c090df5835e..fb8713e34fdef0319ae7afc087266e7341afc37f 100644 (file)
@@ -790,6 +790,17 @@ When using a callable, the callable is passed the ddl element, event name, the `
 Custom DDL
 ----------
 
+Custom DDL phrases are most easily achieved using the :class:`~sqlalchemy.schema.DDL` construct.  This construct works like all the other DDL elements except it accepts a string which is the
+text to be emitted:
+
+.. sourcecode:: python+sql
+
+    DDL("ALTER TABLE users ADD CONSTRAINT "
+        "cst_user_name_length "
+        " CHECK (length(user_name) >= 8)").execute_at("after-create", metadata)
+
+A more comprehensive method of creating libraries of DDL constructs is to use the :ref:`sqlalchemy.ext.compiler_toplevel` extension.   See that chapter for full details.
+
 Adapting Tables to Alternate Metadata 
 ======================================
 
index 95ce639b09ec69a46a4eb0aee8268b010ca4e99e..0e39a6d0e69d523654dbf37a0caeb8247b9383f0 100644 (file)
@@ -1,3 +1,5 @@
+.. _sqlalchemy.ext.compiler_toplevel:
+
 compiler
 ========