umf-access 0.1.0.dev8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- umf_access/__init__.py +109 -0
- umf_access/adoption.py +41 -0
- umf_access/build/__init__.py +2 -0
- umf_access/build/approximate.py +34 -0
- umf_access/build/catalog.py +1626 -0
- umf_access/build/commands.py +394 -0
- umf_access/build/pg_privileges.py +1544 -0
- umf_access/build/privileges.py +134 -0
- umf_access/build/search.py +365 -0
- umf_access/build/unity_search.py +104 -0
- umf_access/bulk.py +227 -0
- umf_access/canonical.py +23 -0
- umf_access/capture.py +410 -0
- umf_access/catalog.py +325 -0
- umf_access/codec_support.py +427 -0
- umf_access/commands.py +93 -0
- umf_access/delta_read.py +758 -0
- umf_access/dsl/__init__.py +148 -0
- umf_access/dsl/_context.py +36 -0
- umf_access/dsl/_expressions.py +625 -0
- umf_access/dsl/_joined.py +4 -0
- umf_access/dsl/_nodes.py +207 -0
- umf_access/dsl/_query.py +5559 -0
- umf_access/dsl/_selection.py +143 -0
- umf_access/dsl/navigation.py +302 -0
- umf_access/dsl/render.py +516 -0
- umf_access/dsl/search.py +343 -0
- umf_access/engine_catalog.py +563 -0
- umf_access/generated_core.py +5 -0
- umf_access/lifecycle/__init__.py +46 -0
- umf_access/lifecycle/_darwin_process_observer.c +306 -0
- umf_access/lifecycle/approval.py +366 -0
- umf_access/lifecycle/backfills.py +79 -0
- umf_access/lifecycle/catalog.py +289 -0
- umf_access/lifecycle/cli.py +231 -0
- umf_access/lifecycle/concurrent.py +196 -0
- umf_access/lifecycle/conversion_policy.py +188 -0
- umf_access/lifecycle/correspondence.py +203 -0
- umf_access/lifecycle/generation_authority_bootstrap.py +1491 -0
- umf_access/lifecycle/generation_authority_session.py +125 -0
- umf_access/lifecycle/generation_enrollment_authority.py +1108 -0
- umf_access/lifecycle/generation_enrollment_ledger.py +698 -0
- umf_access/lifecycle/generation_ingress.py +185 -0
- umf_access/lifecycle/generation_root_registry.py +138 -0
- umf_access/lifecycle/head.py +250 -0
- umf_access/lifecycle/head_view.py +81 -0
- umf_access/lifecycle/host.py +1183 -0
- umf_access/lifecycle/ingress_custody.py +750 -0
- umf_access/lifecycle/ingress_local_postgres.py +7990 -0
- umf_access/lifecycle/ingress_store.py +1488 -0
- umf_access/lifecycle/ledger.py +276 -0
- umf_access/lifecycle/ledger_schema.py +116 -0
- umf_access/lifecycle/mixed.py +593 -0
- umf_access/lifecycle/outcome_schema.py +136 -0
- umf_access/lifecycle/owner_approval_core.py +1810 -0
- umf_access/lifecycle/owner_authority.py +472 -0
- umf_access/lifecycle/owner_bootstrap.py +2077 -0
- umf_access/lifecycle/owner_wire.py +161 -0
- umf_access/lifecycle/phase_fence.py +52 -0
- umf_access/lifecycle/phase_policy.py +422 -0
- umf_access/lifecycle/privileges.py +145 -0
- umf_access/lifecycle/probe.py +39 -0
- umf_access/lifecycle/progress.py +497 -0
- umf_access/lifecycle/roles.py +96 -0
- umf_access/lifecycle/row_originals.py +1712 -0
- umf_access/lifecycle/row_originals_creation.py +759 -0
- umf_access/lifecycle/row_originals_receipt.py +413 -0
- umf_access/lifecycle/seeds.py +99 -0
- umf_access/lifecycle/sql_containment.py +358 -0
- umf_access/lifecycle/sql_containment_cli.py +33 -0
- umf_access/lifecycle/sql_containment_parser.py +20 -0
- umf_access/lifecycle/supervisor_journal_codec.py +1251 -0
- umf_access/lifecycle/table_boundary.py +22 -0
- umf_access/lifecycle/target_custody_codec.py +788 -0
- umf_access/lifecycle/witness.py +72 -0
- umf_access/managed_actions.py +271 -0
- umf_access/managed_bulk.py +353 -0
- umf_access/managed_delta.py +150 -0
- umf_access/managed_support.py +166 -0
- umf_access/manifest_commands.py +278 -0
- umf_access/native_actions.py +1007 -0
- umf_access/native_program.py +570 -0
- umf_access/pages.py +125 -0
- umf_access/postgres_bulk.py +509 -0
- umf_access/postgres_read.py +1230 -0
- umf_access/postgres_search.py +639 -0
- umf_access/protocols.py +665 -0
- umf_access/py.typed +0 -0
- umf_access/related_keys.py +233 -0
- umf_access/reviewed.py +706 -0
- umf_access/search_catalog.py +122 -0
- umf_access/targets.py +312 -0
- umf_access/types.py +220 -0
- umf_access/unified/__init__.py +187 -0
- umf_access/unified/_binding.py +654 -0
- umf_access/unified/head_session.py +144 -0
- umf_access/unified/native_binding.py +143 -0
- umf_access/unified/operation_values.py +173 -0
- umf_access/unified/outcome_values.py +76 -0
- umf_access/unified/session_async.py +161 -0
- umf_access/unified/session_binding.py +108 -0
- umf_access/unified/session_policy.py +152 -0
- umf_access/unified/session_psycopg2.py +70 -0
- umf_access/unified/session_sqlalchemy.py +161 -0
- umf_access/unified/session_sync.py +148 -0
- umf_access/unified/table_reads.py +314 -0
- umf_access/unified/table_writes.py +193 -0
- umf_access/unity_search.py +312 -0
- umf_access/values.py +280 -0
- umf_access/verification.py +64 -0
- umf_access-0.1.0.dev8.dist-info/METADATA +15 -0
- umf_access-0.1.0.dev8.dist-info/RECORD +117 -0
- umf_access-0.1.0.dev8.dist-info/WHEEL +4 -0
- umf_access-0.1.0.dev8.dist-info/entry_points.txt +4 -0
- umf_access-0.1.0.dev8.dist-info/licenses/LICENSE-APACHE +201 -0
- umf_access-0.1.0.dev8.dist-info/licenses/LICENSE-MIT +21 -0
- umf_access-0.1.0.dev8.dist-info/licenses/LICENSE.md +239 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
"""Closed exact scalar selections; no execution or backend SQL authority."""
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Protocol, TypeVar
|
|
6
|
+
|
|
7
|
+
from ._context import CaptureError
|
|
8
|
+
from ._nodes import FieldRef, Node
|
|
9
|
+
|
|
10
|
+
O = TypeVar("O")
|
|
11
|
+
T = TypeVar("T")
|
|
12
|
+
Oc_co = TypeVar("Oc_co", covariant=True)
|
|
13
|
+
Tc_co = TypeVar("Tc_co", covariant=True)
|
|
14
|
+
Jc_co = TypeVar("Jc_co", covariant=True)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
class Selection(Protocol[Oc_co, Tc_co]):
|
|
18
|
+
"""Read-only nominal owner/value markers used by the pinned checkers.
|
|
19
|
+
|
|
20
|
+
Actual capture admits only the closed Column/Agg/Bucket runtime classes and
|
|
21
|
+
validates every original FieldRef; implementing this protocol grants nothing.
|
|
22
|
+
"""
|
|
23
|
+
def _selection_owner(self) -> Oc_co: ...
|
|
24
|
+
def _selection_value(self) -> Tc_co: ...
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class NullableSelection(Selection[Oc_co, Tc_co], Protocol[Oc_co, Tc_co]):
|
|
28
|
+
def _nullable_selection(self) -> bool: ...
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class AggregateSelection(Selection[Oc_co, Tc_co], Protocol[Oc_co, Tc_co]):
|
|
32
|
+
def _aggregate_selection(self) -> bool: ...
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
class GroupKey(NullableSelection[Oc_co, Tc_co], Protocol[Oc_co, Tc_co]):
|
|
36
|
+
def _group_key(self) -> bool: ...
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
class PredicateFor(Protocol[Oc_co]):
|
|
40
|
+
def _predicate_owner(self) -> Oc_co: ...
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
class OrderingFor(Protocol[Oc_co]):
|
|
44
|
+
def _ordering_owner(self) -> Oc_co: ...
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class RequiredRelationship(Protocol[Oc_co, Jc_co]):
|
|
48
|
+
def _join_owner(self) -> Oc_co: ...
|
|
49
|
+
def _join_target(self) -> Jc_co: ...
|
|
50
|
+
def _required_join(self) -> bool: ...
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
class OptionalRelationship(Protocol[Oc_co, Jc_co]):
|
|
54
|
+
def _join_owner(self) -> Oc_co: ...
|
|
55
|
+
def _join_target(self) -> Jc_co: ...
|
|
56
|
+
def _optional_join(self) -> bool: ...
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def scalar_fields(value: FieldRef | Node) -> tuple[FieldRef, ...]:
|
|
62
|
+
if isinstance(value, FieldRef):
|
|
63
|
+
return (value,)
|
|
64
|
+
if value.op == "aggregate" and len(value.args) == 3:
|
|
65
|
+
field = value.args[1]
|
|
66
|
+
if field is None and value.args[0] == "count":
|
|
67
|
+
return ()
|
|
68
|
+
if isinstance(field, FieldRef):
|
|
69
|
+
return (field,)
|
|
70
|
+
if value.op == "bucket_width" and len(value.args) == 2 and isinstance(value.args[0], FieldRef):
|
|
71
|
+
return (value.args[0],)
|
|
72
|
+
raise CaptureError("CAPTURE_UNSUPPORTED", "unknown scalar expression")
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Exact overloads deliberately exclude string, binary and bool summation.
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
from ._expressions import (
|
|
101
|
+
Agg as Agg, # noqa: PLC0414
|
|
102
|
+
)
|
|
103
|
+
from ._expressions import (
|
|
104
|
+
Bucket as Bucket, # noqa: PLC0414
|
|
105
|
+
)
|
|
106
|
+
from ._expressions import (
|
|
107
|
+
approx_count_distinct as approx_count_distinct, # noqa: PLC0414
|
|
108
|
+
)
|
|
109
|
+
from ._expressions import (
|
|
110
|
+
avg_ as avg_, # noqa: PLC0414
|
|
111
|
+
)
|
|
112
|
+
from ._expressions import (
|
|
113
|
+
bucket_width as bucket_width, # noqa: PLC0414
|
|
114
|
+
)
|
|
115
|
+
from ._expressions import (
|
|
116
|
+
count as count, # noqa: PLC0414
|
|
117
|
+
)
|
|
118
|
+
from ._expressions import (
|
|
119
|
+
count_distinct as count_distinct, # noqa: PLC0414
|
|
120
|
+
)
|
|
121
|
+
from ._expressions import (
|
|
122
|
+
max_ as max_, # noqa: PLC0414
|
|
123
|
+
)
|
|
124
|
+
from ._expressions import (
|
|
125
|
+
min_ as min_, # noqa: PLC0414
|
|
126
|
+
)
|
|
127
|
+
from ._expressions import (
|
|
128
|
+
scalar as scalar, # noqa: PLC0414
|
|
129
|
+
)
|
|
130
|
+
from ._expressions import (
|
|
131
|
+
sum_ as sum_, # noqa: PLC0414
|
|
132
|
+
)
|
|
133
|
+
|
|
134
|
+
ProjectionResult_co = TypeVar("ProjectionResult_co", covariant=True)
|
|
135
|
+
|
|
136
|
+
|
|
137
|
+
class GeneratedProjection(Protocol[Oc_co, ProjectionResult_co]):
|
|
138
|
+
"""Inert generated class witnesses; runtime still validates pinned Fields."""
|
|
139
|
+
|
|
140
|
+
@property
|
|
141
|
+
def UMF_PROJECTION_OWNER(self) -> type[Oc_co]: ...
|
|
142
|
+
|
|
143
|
+
def _umf_projection_model(self) -> type[ProjectionResult_co]: ...
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
"""Generated selected-Key navigation metadata, distinct from relationship Keys."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
from dataclasses import dataclass, field
|
|
7
|
+
from typing import Generic, Literal, Never
|
|
8
|
+
|
|
9
|
+
from typing_extensions import TypeVar
|
|
10
|
+
|
|
11
|
+
from ._context import CaptureError, require_capture
|
|
12
|
+
from ._expressions import Join, OptionalJoin, Related, RequiredJoin
|
|
13
|
+
from ._nodes import FieldRef, RecordRef
|
|
14
|
+
|
|
15
|
+
Owner = TypeVar("Owner")
|
|
16
|
+
Target = TypeVar("Target")
|
|
17
|
+
SourceKey = TypeVar("SourceKey")
|
|
18
|
+
TargetKey = TypeVar("TargetKey")
|
|
19
|
+
RelationKey = TypeVar("RelationKey")
|
|
20
|
+
InverseKey = TypeVar("InverseKey", default=Never)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def _same_record(left: RecordRef, right: RecordRef) -> bool:
|
|
24
|
+
return (left.module, left.element, left.source) == (
|
|
25
|
+
right.module,
|
|
26
|
+
right.element,
|
|
27
|
+
right.source,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _relation_target(relation: object) -> RecordRef:
|
|
32
|
+
if isinstance(relation, Join):
|
|
33
|
+
return relation.target
|
|
34
|
+
if isinstance(relation, ManyNavigation):
|
|
35
|
+
target = relation.key_target
|
|
36
|
+
if (
|
|
37
|
+
not isinstance(target, RecordRef)
|
|
38
|
+
or target.source is None
|
|
39
|
+
or target.key_id is None
|
|
40
|
+
or not target.key
|
|
41
|
+
):
|
|
42
|
+
raise TypeError("original many relationship Key target required")
|
|
43
|
+
return target
|
|
44
|
+
raise TypeError("original generated navigation family required")
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def _roots(
|
|
48
|
+
relation: Join[Owner, Target, RelationKey]
|
|
49
|
+
| ManyNavigation[Owner, Target, SourceKey, TargetKey, RelationKey, InverseKey],
|
|
50
|
+
source: RecordRef,
|
|
51
|
+
target: RecordRef,
|
|
52
|
+
) -> None:
|
|
53
|
+
if not isinstance(source, RecordRef) or not isinstance(target, RecordRef):
|
|
54
|
+
raise TypeError("generated navigation roots required")
|
|
55
|
+
if source.source is None or target.source is None:
|
|
56
|
+
raise TypeError("navigation requires pinned generated sources")
|
|
57
|
+
if (relation.ref.module, relation.ref.element, relation.ref.source) != (
|
|
58
|
+
source.module,
|
|
59
|
+
source.element,
|
|
60
|
+
source.source,
|
|
61
|
+
) or not _same_record(_relation_target(relation), target):
|
|
62
|
+
raise TypeError("navigation roots differ from the original relationship")
|
|
63
|
+
if (
|
|
64
|
+
not source.key
|
|
65
|
+
or not target.key
|
|
66
|
+
or source.key_id is None
|
|
67
|
+
or target.key_id is None
|
|
68
|
+
):
|
|
69
|
+
raise TypeError(
|
|
70
|
+
"navigation requires explicitly selected source and target Keys"
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def _plain(source: RecordRef, target: RecordRef, relation: object) -> None:
|
|
75
|
+
if not isinstance(relation, (Join, ManyNavigation)):
|
|
76
|
+
raise TypeError("original generated relationship required")
|
|
77
|
+
if any(
|
|
78
|
+
ref.alias is not None
|
|
79
|
+
for ref in (source, target, relation.ref, _relation_target(relation))
|
|
80
|
+
):
|
|
81
|
+
raise CaptureError(
|
|
82
|
+
"WEFT_BLOCKED",
|
|
83
|
+
"WR-A6 aliased navigation has no qualified original source-alias profile",
|
|
84
|
+
)
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
@dataclass(frozen=True)
|
|
88
|
+
class InverseNavigation(
|
|
89
|
+
Related[Owner, InverseKey],
|
|
90
|
+
Generic[Owner, Target, TargetKey, RelationKey, InverseKey],
|
|
91
|
+
):
|
|
92
|
+
relationship: Join[Target, Owner, RelationKey]
|
|
93
|
+
source_query: RecordRef
|
|
94
|
+
target_query: RecordRef
|
|
95
|
+
|
|
96
|
+
def __post_init__(self) -> None:
|
|
97
|
+
super().__post_init__()
|
|
98
|
+
if not isinstance(self.relationship, Join):
|
|
99
|
+
raise TypeError(
|
|
100
|
+
"original to-one inverse navigation requires its Join family"
|
|
101
|
+
)
|
|
102
|
+
_roots(self.relationship, self.target_query, self.source_query)
|
|
103
|
+
if self.direction != "inverse" or (
|
|
104
|
+
self.source_query.module,
|
|
105
|
+
self.source_query.element,
|
|
106
|
+
self.source_query.source,
|
|
107
|
+
) != (self.ref.module, self.ref.element, self.ref.source):
|
|
108
|
+
raise TypeError("inverse navigation requires its original target owner")
|
|
109
|
+
|
|
110
|
+
|
|
111
|
+
@dataclass(frozen=True)
|
|
112
|
+
class RequiredNavigation(
|
|
113
|
+
RequiredJoin[Owner, Target, RelationKey],
|
|
114
|
+
Generic[Owner, Target, SourceKey, TargetKey, RelationKey, InverseKey],
|
|
115
|
+
):
|
|
116
|
+
source_query: RecordRef = field(kw_only=True)
|
|
117
|
+
target_query: RecordRef = field(kw_only=True)
|
|
118
|
+
inverse_key_target: RecordRef | None = field(default=None, kw_only=True)
|
|
119
|
+
|
|
120
|
+
def __post_init__(self) -> None:
|
|
121
|
+
super().__post_init__()
|
|
122
|
+
_roots(self, self.source_query, self.target_query)
|
|
123
|
+
if self.inverse_key_target is not None and (
|
|
124
|
+
not _same_record(self.inverse_key_target, self.source_query)
|
|
125
|
+
or self.inverse_key_target.key_id is None
|
|
126
|
+
):
|
|
127
|
+
raise TypeError(
|
|
128
|
+
"original inverse Key belongs to the original source Record"
|
|
129
|
+
)
|
|
130
|
+
|
|
131
|
+
def inverse(
|
|
132
|
+
self,
|
|
133
|
+
) -> InverseNavigation[Target, Owner, SourceKey, RelationKey, InverseKey]:
|
|
134
|
+
require_capture()
|
|
135
|
+
_plain(self.source_query, self.target_query, self)
|
|
136
|
+
ref = FieldRef(
|
|
137
|
+
source=self.ref.source,
|
|
138
|
+
module=self.target_query.module,
|
|
139
|
+
element=self.target_query.element,
|
|
140
|
+
field=self.ref.field,
|
|
141
|
+
field_module=self.ref.field_module,
|
|
142
|
+
logical_name=self.ref.logical_name,
|
|
143
|
+
)
|
|
144
|
+
return InverseNavigation(
|
|
145
|
+
ref,
|
|
146
|
+
self,
|
|
147
|
+
self.target_query,
|
|
148
|
+
self.source_query,
|
|
149
|
+
key_target=self.inverse_key_target,
|
|
150
|
+
direction="inverse",
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
@dataclass(frozen=True)
|
|
155
|
+
class OptionalNavigation(
|
|
156
|
+
OptionalJoin[Owner, Target, RelationKey],
|
|
157
|
+
Generic[Owner, Target, SourceKey, TargetKey, RelationKey, InverseKey],
|
|
158
|
+
):
|
|
159
|
+
source_query: RecordRef = field(kw_only=True)
|
|
160
|
+
target_query: RecordRef = field(kw_only=True)
|
|
161
|
+
inverse_key_target: RecordRef | None = field(default=None, kw_only=True)
|
|
162
|
+
|
|
163
|
+
def __post_init__(self) -> None:
|
|
164
|
+
super().__post_init__()
|
|
165
|
+
_roots(self, self.source_query, self.target_query)
|
|
166
|
+
if self.inverse_key_target is not None and (
|
|
167
|
+
not _same_record(self.inverse_key_target, self.source_query)
|
|
168
|
+
or self.inverse_key_target.key_id is None
|
|
169
|
+
):
|
|
170
|
+
raise TypeError(
|
|
171
|
+
"original inverse Key belongs to the original source Record"
|
|
172
|
+
)
|
|
173
|
+
|
|
174
|
+
def inverse(
|
|
175
|
+
self,
|
|
176
|
+
) -> InverseNavigation[Target, Owner, SourceKey, RelationKey, InverseKey]:
|
|
177
|
+
require_capture()
|
|
178
|
+
_plain(self.source_query, self.target_query, self)
|
|
179
|
+
ref = FieldRef(
|
|
180
|
+
source=self.ref.source,
|
|
181
|
+
module=self.target_query.module,
|
|
182
|
+
element=self.target_query.element,
|
|
183
|
+
field=self.ref.field,
|
|
184
|
+
field_module=self.ref.field_module,
|
|
185
|
+
logical_name=self.ref.logical_name,
|
|
186
|
+
)
|
|
187
|
+
return InverseNavigation(
|
|
188
|
+
ref,
|
|
189
|
+
self,
|
|
190
|
+
self.target_query,
|
|
191
|
+
self.source_query,
|
|
192
|
+
key_target=self.inverse_key_target,
|
|
193
|
+
direction="inverse",
|
|
194
|
+
)
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
@dataclass(frozen=True)
|
|
198
|
+
class InverseManyNavigation(
|
|
199
|
+
Related[Owner, InverseKey],
|
|
200
|
+
Generic[Owner, Target, SourceKey, TargetKey, RelationKey, InverseKey],
|
|
201
|
+
):
|
|
202
|
+
relationship: ManyNavigation[
|
|
203
|
+
Target, Owner, TargetKey, SourceKey, RelationKey, InverseKey
|
|
204
|
+
]
|
|
205
|
+
source_query: RecordRef
|
|
206
|
+
target_query: RecordRef
|
|
207
|
+
|
|
208
|
+
def __post_init__(self) -> None:
|
|
209
|
+
super().__post_init__()
|
|
210
|
+
if not isinstance(self.relationship, ManyNavigation):
|
|
211
|
+
raise TypeError("original forward many relationship required")
|
|
212
|
+
_roots(self.relationship, self.target_query, self.source_query)
|
|
213
|
+
if (
|
|
214
|
+
self.direction != "inverse"
|
|
215
|
+
or self.source_query != self.relationship.target_query
|
|
216
|
+
or self.target_query != self.relationship.source_query
|
|
217
|
+
or self.key_target != self.relationship.inverse_key_target
|
|
218
|
+
or (self.ref.module, self.ref.element, self.ref.source)
|
|
219
|
+
!= (
|
|
220
|
+
self.source_query.module,
|
|
221
|
+
self.source_query.element,
|
|
222
|
+
self.source_query.source,
|
|
223
|
+
)
|
|
224
|
+
or (self.ref.field, self.ref.field_module)
|
|
225
|
+
!= (self.relationship.ref.field, self.relationship.ref.field_module)
|
|
226
|
+
):
|
|
227
|
+
raise TypeError(
|
|
228
|
+
"inverse many navigation must retain original owner, Keys and relationship"
|
|
229
|
+
)
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
@dataclass(frozen=True)
|
|
233
|
+
class ManyNavigation(
|
|
234
|
+
Related[Owner, RelationKey],
|
|
235
|
+
Generic[Owner, Target, SourceKey, TargetKey, RelationKey, InverseKey],
|
|
236
|
+
):
|
|
237
|
+
source_query: RecordRef = field(kw_only=True)
|
|
238
|
+
target_query: RecordRef = field(kw_only=True)
|
|
239
|
+
inverse_key_target: RecordRef | None = field(default=None, kw_only=True)
|
|
240
|
+
|
|
241
|
+
def __post_init__(self) -> None:
|
|
242
|
+
super().__post_init__()
|
|
243
|
+
_roots(self, self.source_query, self.target_query)
|
|
244
|
+
if self.direction != "forward":
|
|
245
|
+
raise TypeError("original many navigation must be forward")
|
|
246
|
+
if self.inverse_key_target is not None and (
|
|
247
|
+
not _same_record(self.inverse_key_target, self.source_query)
|
|
248
|
+
or self.inverse_key_target.key_id is None
|
|
249
|
+
or not self.inverse_key_target.key
|
|
250
|
+
):
|
|
251
|
+
raise TypeError(
|
|
252
|
+
"original inverse relationship Key belongs to its original source"
|
|
253
|
+
)
|
|
254
|
+
|
|
255
|
+
def inverse(
|
|
256
|
+
self,
|
|
257
|
+
) -> InverseManyNavigation[
|
|
258
|
+
Target, Owner, TargetKey, SourceKey, RelationKey, InverseKey
|
|
259
|
+
]:
|
|
260
|
+
require_capture()
|
|
261
|
+
_plain(self.source_query, self.target_query, self)
|
|
262
|
+
ref = FieldRef(
|
|
263
|
+
source=self.ref.source,
|
|
264
|
+
module=self.target_query.module,
|
|
265
|
+
element=self.target_query.element,
|
|
266
|
+
field=self.ref.field,
|
|
267
|
+
field_module=self.ref.field_module,
|
|
268
|
+
logical_name=self.ref.logical_name,
|
|
269
|
+
)
|
|
270
|
+
return InverseManyNavigation(
|
|
271
|
+
ref,
|
|
272
|
+
self,
|
|
273
|
+
self.target_query,
|
|
274
|
+
self.source_query,
|
|
275
|
+
key_target=self.inverse_key_target,
|
|
276
|
+
direction="inverse",
|
|
277
|
+
)
|
|
278
|
+
|
|
279
|
+
|
|
280
|
+
def navigation_parts(
|
|
281
|
+
value: object,
|
|
282
|
+
) -> tuple[RecordRef, RecordRef, object, Literal["forward", "inverse"]]:
|
|
283
|
+
require_capture()
|
|
284
|
+
direction: Literal["forward", "inverse"]
|
|
285
|
+
if isinstance(value, (RequiredNavigation, OptionalNavigation, ManyNavigation)):
|
|
286
|
+
source, target, relationship, direction = (
|
|
287
|
+
value.source_query,
|
|
288
|
+
value.target_query,
|
|
289
|
+
value,
|
|
290
|
+
"forward",
|
|
291
|
+
)
|
|
292
|
+
elif isinstance(value, (InverseNavigation, InverseManyNavigation)):
|
|
293
|
+
source, target, relationship, direction = (
|
|
294
|
+
value.source_query,
|
|
295
|
+
value.target_query,
|
|
296
|
+
value.relationship,
|
|
297
|
+
"inverse",
|
|
298
|
+
)
|
|
299
|
+
else:
|
|
300
|
+
raise TypeError("related requires generated selected-Key navigation metadata")
|
|
301
|
+
_plain(source, target, relationship)
|
|
302
|
+
return source, target, relationship, direction
|