summaryrefslogtreecommitdiff
path: root/lib/sqlalchemy/orm/util.py
diff options
context:
space:
mode:
authorMike Bayer <mike_mp@zzzcomputing.com>2019-11-20 12:15:57 -0500
committerMike Bayer <mike_mp@zzzcomputing.com>2019-11-22 13:12:27 -0500
commit22d1f0706bd6a6742ad13f0bec75b04e705ff46b (patch)
tree94fc9173cc8b4fdc064a4bd56b6ad1baa00183ea /lib/sqlalchemy/orm/util.py
parent3ceb87da1a66f455444e69ba25ac18ea26d8751e (diff)
downloadsqlalchemy-22d1f0706bd6a6742ad13f0bec75b04e705ff46b.tar.gz
Warn for settings that don't work with viewonly=True
Setting persistence-related flags on :func:`.relationship` while also setting viewonly=True will now emit a regular warning, as these flags do not make sense for a viewonly=True relationship. In particular, the "cascade" settings have their own warning that is generated based on the individual values, such as "delete, delete-orphan", that should not apply to a viewonly relationship. Note however that in the case of "cascade", these settings are still erroneously taking effect even though the relationship is set up as "viewonly". In 1.4, all persistence-related cascade settings will be disallowed on a viewonly=True relationship in order to resolve this issue. Fixes: #4993 Change-Id: I4b607a96a7de2ffa15303a27fd93c162a681556d
Diffstat (limited to 'lib/sqlalchemy/orm/util.py')
-rw-r--r--lib/sqlalchemy/orm/util.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/sqlalchemy/orm/util.py b/lib/sqlalchemy/orm/util.py
index c86993678..b96387c08 100644
--- a/lib/sqlalchemy/orm/util.py
+++ b/lib/sqlalchemy/orm/util.py
@@ -60,6 +60,8 @@ class CascadeOptions(frozenset):
)
_allowed_cascades = all_cascades
+ _viewonly_cascades = ["expunge", "all", "none", "refresh-expire"]
+
__slots__ = (
"save_update",
"delete",