|
| 1 | +from dataclasses import dataclass |
1 | 2 | from datetime import datetime, timezone |
2 | 3 | from functools import wraps |
3 | 4 | import logging |
4 | 5 | import json |
5 | 6 |
|
6 | 7 | from labelbox import utils |
7 | | -from labelbox.exceptions import InvalidQueryError, InvalidAttributeError |
| 8 | +from labelbox.exceptions import InvalidQueryError, InvalidAttributeError, OperationNotSupportedException |
8 | 9 | from labelbox.orm import query |
9 | 10 | from labelbox.orm.model import Field, Relationship, Entity |
10 | 11 | from labelbox.pagination import PaginatedCollection |
@@ -123,6 +124,7 @@ def __init__(self, source, relationship, value=None): |
123 | 124 | self.supports_sorting = True |
124 | 125 | self.filter_on_id = True |
125 | 126 | self.value = value |
| 127 | + self.config = relationship.config |
126 | 128 |
|
127 | 129 | def __call__(self, *args, **kwargs): |
128 | 130 | """ Forwards the call to either `_to_many` or `_to_one` methods, |
@@ -191,6 +193,10 @@ def connect(self, other): |
191 | 193 |
|
192 | 194 | def disconnect(self, other): |
193 | 195 | """ Disconnects source object of this manager from the `other` object. """ |
| 196 | + if not self.config.disconnect_supported: |
| 197 | + raise OperationNotSupportedException( |
| 198 | + "Disconnect is not supported for this relationship") |
| 199 | + |
194 | 200 | query_string, params = query.update_relationship( |
195 | 201 | self.source, other, self.relationship, "disconnect") |
196 | 202 | self.source.client.execute(query_string, params) |
|
0 commit comments