From: Mike Bayer Date: Sun, 3 Jan 2010 18:22:50 +0000 (+0000) Subject: add a brief doc for custom DDL X-Git-Tag: rel_0_6beta1~100 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=87ff3c679c5ac02313e232ae67ca1cb3b17e0c6d;p=thirdparty%2Fsqlalchemy%2Fsqlalchemy.git add a brief doc for custom DDL --- diff --git a/doc/build/metadata.rst b/doc/build/metadata.rst index 078162f464..fb8713e34f 100644 --- a/doc/build/metadata.rst +++ b/doc/build/metadata.rst @@ -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 ====================================== diff --git a/doc/build/reference/ext/compiler.rst b/doc/build/reference/ext/compiler.rst index 95ce639b09..0e39a6d0e6 100644 --- a/doc/build/reference/ext/compiler.rst +++ b/doc/build/reference/ext/compiler.rst @@ -1,3 +1,5 @@ +.. _sqlalchemy.ext.compiler_toplevel: + compiler ========