diff options
author | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-14 20:26:38 -0400 |
---|---|---|
committer | Mike Bayer <mike_mp@zzzcomputing.com> | 2014-07-14 20:26:38 -0400 |
commit | d2193f53c10d29a7a9b1846ebf322fbced55041f (patch) | |
tree | c4f97c44c32abfe913b0bc5c05c332e696f05c7a /lib/sqlalchemy/sql/elements.py | |
parent | 6fd0bc7c62849a1dc34ca7d93aeeaaff25897648 (diff) | |
download | sqlalchemy-d2193f53c10d29a7a9b1846ebf322fbced55041f.tar.gz |
- Fix bug in naming convention feature where using a check
constraint convention that includes ``constraint_name`` would
then force all :class:`.Boolean` and :class:`.Enum` types to
require names as well, as these implicitly create a
constraint, even if the ultimate target backend were one that does
not require generation of the constraint such as Postgresql.
The mechanics of naming conventions for these particular
constraints has been reorganized such that the naming
determination is done at DDL compile time, rather than at
constraint/table construction time.
fixes #3067
Diffstat (limited to 'lib/sqlalchemy/sql/elements.py')
-rw-r--r-- | lib/sqlalchemy/sql/elements.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/sqlalchemy/sql/elements.py b/lib/sqlalchemy/sql/elements.py index 3882d9e5b..d273d9881 100644 --- a/lib/sqlalchemy/sql/elements.py +++ b/lib/sqlalchemy/sql/elements.py @@ -3201,6 +3201,22 @@ class _truncated_label(quoted_name): def apply_map(self, map_): return self + +class _defer_name(_truncated_label): + """mark a name as 'deferred' for the purposes of automated name + generation. + + """ + def __new__(cls, value): + if value is None: + return _defer_none_name('_unnamed_') + else: + return super(_defer_name, cls).__new__(cls, value) + + +class _defer_none_name(_defer_name): + """indicate a 'deferred' name that was ultimately the value None.""" + # for backwards compatibility in case # someone is re-implementing the # _truncated_identifier() sequence in a custom |