summaryrefslogtreecommitdiff
path: root/doc
diff options
context:
space:
mode:
authorRamonWill <ramonwilliams@hotmail.co.uk>2020-08-30 09:05:06 -0400
committerRamonWill <ramonwilliams@hotmail.co.uk>2020-08-31 16:13:29 +0100
commit2e887c7a4105a973a015b9ecbb4ea5a11dafb26a (patch)
treea8af4588ad1127b943847e4c8c70228a3efe859c /doc
parent34dfd7eb88f42e259d3049dbbc823a97b11cb555 (diff)
downloadsqlalchemy-2e887c7a4105a973a015b9ecbb4ea5a11dafb26a.tar.gz
Include PostgreSQL in trigger test and correct documentation example
Include PostgreSQL dialect in trigger test and correct DDL example in documentation A user highlighted that the syntax in the DDL trigger example was incorrect for PostgreSQL. The trigger tests where also skipping the PostgreSQL dialect until the syntax was corrected. This PR fixes both of these issues. This pull request is: - [X ] A documentation / typographical error fix - Good to go, no issue or tests are needed - [ ] A short code fix - please include the issue number, and create an issue if none exists, which must include a complete example of the issue. one line code fixes without an issue and demonstration will not be accepted. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. one line code fixes without tests will not be accepted. - [ ] A new feature implementation - please include the issue number, and create an issue if none exists, which must include a complete example of how the feature would look. - Please include: `Fixes: #<issue number>` in the commit message - please include tests. **Have a nice day!** Fixes: #4037 Closes: #5548 Pull-request: https://github.com/sqlalchemy/sqlalchemy/pull/5548 Pull-request-sha: 1db5e47adb90f9d51e247711dcfdbb274fb7bf73 Change-Id: I06edbcab99c82a3ce25581b81f8d2a4a028c07c3
Diffstat (limited to 'doc')
-rw-r--r--doc/build/core/ddl.rst19
1 files changed, 16 insertions, 3 deletions
diff --git a/doc/build/core/ddl.rst b/doc/build/core/ddl.rst
index 30619a419..9c2fed198 100644
--- a/doc/build/core/ddl.rst
+++ b/doc/build/core/ddl.rst
@@ -59,9 +59,24 @@ the PostgreSQL backend, we could invoke this as::
Column('data', String(50))
)
+ func = DDL(
+ "CREATE FUNCTION my_func() "
+ "RETURNS TRIGGER AS $$ "
+ "BEGIN "
+ "NEW.data := 'ins'; "
+ "RETURN NEW; "
+ "END; $$ LANGUAGE PLPGSQL"
+ )
+
trigger = DDL(
"CREATE TRIGGER dt_ins BEFORE INSERT ON mytable "
- "FOR EACH ROW BEGIN SET NEW.data='ins'; END"
+ "FOR EACH ROW EXECUTE PROCEDURE my_func();"
+ )
+
+ event.listen(
+ mytable,
+ 'after_create',
+ func.execute_if(dialect='postgresql')
)
event.listen(
@@ -296,5 +311,3 @@ DDL Expression Constructs API
.. autoclass:: DropSchema
:members:
:undoc-members:
-
-