diff options
| author | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-08 11:14:22 -0500 |
|---|---|---|
| committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2020-11-08 12:45:34 -0500 |
| commit | c6d869f814d2e8ffe03e519c59cf35f7a4927e1c (patch) | |
| tree | 4017104ab8f89f451b60c788262069c91c0451aa /lib/sqlalchemy/sql/ddl.py | |
| parent | 89e748d7ad4426077313aaec916b41f999ae5a34 (diff) | |
| download | sqlalchemy-c6d869f814d2e8ffe03e519c59cf35f7a4927e1c.tar.gz | |
Allow dialect-specific stringification
Dialect-specific constructs such as
:meth:`_postgresql.Insert.on_conflict_do_update` can now stringify in-place
without the need to specify an explicit dialect object. The constructs,
when called upon for ``str()``, ``print()``, etc. now have internal
direction to call upon their appropriate dialect rather than the
"default"dialect which doesn't know how to stringify these. The approach
is also adapted to generic schema-level create/drop such as
:class:`_schema.AddConstraint`, which will adapt its stringify dialect to
one indicated by the element within it, such as the
:class:`_postgresql.ExcludeConstraint` object.
mostly towards being able to provide doctest-style
examples for "on conflict" constructs using print statements.
Change-Id: I4b855516fe6dee2df77744c1bb21a373d7fbab93
Diffstat (limited to 'lib/sqlalchemy/sql/ddl.py')
| -rw-r--r-- | lib/sqlalchemy/sql/ddl.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/ddl.py b/lib/sqlalchemy/sql/ddl.py index 3bd831292..f1012292b 100644 --- a/lib/sqlalchemy/sql/ddl.py +++ b/lib/sqlalchemy/sql/ddl.py @@ -373,6 +373,10 @@ class _CreateDropBase(DDLElement): self.element = element self.bind = bind + @property + def stringify_dialect(self): + return self.element.create_drop_stringify_dialect + def _create_rule_disable(self, compiler): """Allow disable of _create_rule using a callable. |
