From 87ff3c679c5ac02313e232ae67ca1cb3b17e0c6d Mon Sep 17 00:00:00 2001 From: Mike Bayer Date: Sun, 3 Jan 2010 18:22:50 +0000 Subject: [PATCH] add a brief doc for custom DDL --- doc/build/metadata.rst | 11 +++++++++++ doc/build/reference/ext/compiler.rst | 2 ++ 2 files changed, 13 insertions(+) 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 ======== -- 2.47.3