summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/event/base.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2021-02-04 12:09:54 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2021-02-04 12:11:41 -0500
commit9660e94e35be438b0d51cd87e6ccb4047a332c15 (patch)
tree0a888b4fb18430618bca045b3c2456dff893f6cb /lib/sqlalchemy/event/base.py
parente91d918fc24d678a413feb3744e70014f54172c7 (diff)
downloadsqlalchemy-9660e94e35be438b0d51cd87e6ccb4047a332c15.tar.gz
Accommodate column-based naming conventions for pk constraint
Repaired / implemented support for primary key constraint naming conventions that use column names/keys/etc as part of the convention. In particular, this includes that the :class:`.PrimaryKeyConstraint` object that's automatically associated with a :class:`.schema.Table` will update its name as new primary key :class:`_schema.Column` objects are added to the table and then to the constraint. Internal failure modes related to this constraint construction process including no columns present, no name present or blank name present are now accommodated. Fixes: #5919 Change-Id: Ic2800b50f4a4cd5978bec48cefea0a2e198e0123
Diffstat (limited to 'lib/sqlalchemy/event/base.py')
-rw-r--r--lib/sqlalchemy/event/base.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/sqlalchemy/event/base.py b/lib/sqlalchemy/event/base.py
index 181db0cf2..fb75d9e3e 100644
--- a/lib/sqlalchemy/event/base.py
+++ b/lib/sqlalchemy/event/base.py
@@ -29,7 +29,13 @@ _registrars = util.defaultdict(list)
def _is_event_name(name):
- return not name.startswith("_") and name != "dispatch"
+ # _sa_event prefix is special to support internal-only event names.
+ # most event names are just plain method names that aren't
+ # underscored.
+
+ return (
+ not name.startswith("_") and name != "dispatch"
+ ) or name.startswith("_sa_event")
class _UnpickleDispatch(object):