Skip to content

Commit fe58e00

Browse files
committed
Deprecate dj.U join instead of redirecting to restrict
- dj.U * table now raises a deprecation error instead of redirecting to dj.U & table (they are different operations) - Remove unused variables in lineage.py
1 parent 0c593c8 commit fe58e00

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

src/datajoint/expression.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,7 @@ def __matmul__(self, other):
279279
Use .join(other, semantic_check=False) for permissive joins.
280280
"""
281281
raise DataJointError(
282-
"The @ operator has been removed in DataJoint 2.0. "
283-
"Use .join(other, semantic_check=False) for permissive joins."
282+
"The @ operator has been removed in DataJoint 2.0. " "Use .join(other, semantic_check=False) for permissive joins."
284283
)
285284

286285
def join(self, other, semantic_check=True, left=False):
@@ -299,9 +298,9 @@ def join(self, other, semantic_check=True, left=False):
299298
a * b is short for a.join(b)
300299
a.join(b, semantic_check=False) for permissive joins
301300
"""
302-
# Handle U objects: redirect to U's restriction operation
301+
# U joins are deprecated - raise error directing to use & instead
303302
if isinstance(other, U):
304-
return other & self
303+
raise DataJointError("dj.U(...) * table is deprecated in DataJoint 2.0. " "Use dj.U(...) & table instead.")
305304
if inspect.isclass(other) and issubclass(other, QueryExpression):
306305
other = other() # instantiate
307306
if not isinstance(other, QueryExpression):
@@ -310,9 +309,7 @@ def join(self, other, semantic_check=True, left=False):
310309
assert_join_compatibility(self, other)
311310
# Only join on homologous namesakes (same name AND same lineage)
312311
join_attributes = set(
313-
n
314-
for n in self.heading.names
315-
if n in other.heading.names and self.heading[n].lineage == other.heading[n].lineage
312+
n for n in self.heading.names if n in other.heading.names and self.heading[n].lineage == other.heading[n].lineage
316313
)
317314
# needs subquery if self's FROM clause has common attributes with other's FROM clause
318315
need_subquery1 = need_subquery2 = bool(
@@ -846,18 +843,13 @@ def __mul__(self, other):
846843
dj.U * table is deprecated in DataJoint 2.0.
847844
Use dj.U & table instead.
848845
"""
849-
raise DataJointError(
850-
"dj.U(...) * table is deprecated in DataJoint 2.0. "
851-
"Use dj.U(...) & table instead."
852-
)
846+
raise DataJointError("dj.U(...) * table is deprecated in DataJoint 2.0. " "Use dj.U(...) & table instead.")
853847

854848
def __sub__(self, other):
855849
"""
856850
dj.U - table produces an infinite set and is not supported.
857851
"""
858-
raise DataJointError(
859-
"dj.U(...) - table produces an infinite set and is not supported."
860-
)
852+
raise DataJointError("dj.U(...) - table produces an infinite set and is not supported.")
861853

862854
def aggr(self, group, **named_attributes):
863855
"""

src/datajoint/lineage.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -157,17 +157,12 @@ def compute_lineage_from_dependencies(connection, full_table_name, attribute_nam
157157
attr_map = props.get("attr_map", {})
158158
if attribute_name in attr_map:
159159
parent_attr = attr_map[attribute_name]
160-
parent_parts = parent_table.replace("`", "").split(".")
161-
parent_db = parent_parts[0]
162-
parent_tbl = parent_parts[1]
163160

164161
# Get parent's primary key
165162
parent_pk = connection.dependencies.nodes.get(parent_table, {}).get("primary_key", set())
166163

167164
# Recursively trace to origin
168-
return compute_lineage_from_dependencies(
169-
connection, parent_table, parent_attr, list(parent_pk)
170-
)
165+
return compute_lineage_from_dependencies(connection, parent_table, parent_attr, list(parent_pk))
171166

172167
# Not inherited - check if primary key
173168
if attribute_name in primary_key:

0 commit comments

Comments
 (0)