File tree Expand file tree Collapse file tree 3 files changed +17
-12
lines changed
Expand file tree Collapse file tree 3 files changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -130,8 +130,9 @@ def get_mappings(
130130
131131 Optionally provide a type to filter results.
132132
133- :param object_id:
134- :param as_source:
133+ :param object_id: ID of object to get mappings for
134+ :param as_source: If ``True``, object_id is treated as the source. If ``False``,
135+ ``object_id`` is treated as the destination.
135136 :param mapping_type: The type of mapping to retrieve (defaults to `None` to
136137 retrieve all mappings for the source ID)
137138 :return: iterable collection of mapping descriptors (empty if no matching mappings exist)
Original file line number Diff line number Diff line change @@ -272,8 +272,9 @@ def get_mappings(
272272
273273 Optionally provide a type to filter results.
274274
275- :param object_id:
276- :param as_source:
275+ :param object_id: ID of object to get mappings for
276+ :param as_source: If ``True``, object_id is treated as the source. If ``False``,
277+ ``object_id`` is treated as the destination.
277278 :param mapping_type: The type of mapping to retrieve (defaults to `None` to
278279 retrieve all mappings for the source ID)
279280 :return: iterable collection of mapping descriptors (empty if no matching mappings exist)
Original file line number Diff line number Diff line change @@ -530,23 +530,26 @@ def delete_mapping(self, mapping: metadata.VariationMapping) -> None:
530530
531531 def get_mappings (
532532 self ,
533- source_object_id : str ,
533+ object_id : str ,
534+ as_source : bool ,
534535 mapping_type : metadata .VariationMappingType | None = None ,
535536 ) -> Iterable [metadata .VariationMapping ]:
536- """Return an iterable of mappings from the source ID
537+ """Return an iterable of mappings
537538
538539 Optionally provide a type to filter results.
539540
540- :param source_object_id: ID of the source object
541+ :param object_id: ID of object to get mappings for
542+ :param as_source: If ``True``, object_id is treated as the source. If ``False``,
543+ ``object_id`` is treated as the destination.
541544 :param mapping_type: The type of mapping to retrieve (defaults to `None` to
542545 retrieve all mappings for the source ID)
543546 :return: iterable collection of mapping descriptors (empty if no matching mappings exist)
544547 """
545- stmt = (
546- select ( orm . VariationMapping )
547- .where (orm .VariationMapping .source_id == source_object_id )
548- . limit ( self . MAX_ROWS )
549- )
548+ stmt = select ( orm . VariationMapping ). limit ( self . MAX_ROWS )
549+ if as_source :
550+ stmt = stmt .where (orm .VariationMapping .source_id == object_id )
551+ else :
552+ stmt = stmt . where ( orm . VariationMapping . dest_id == object_id )
550553 if mapping_type :
551554 stmt = stmt .where (orm .VariationMapping .mapping_type == mapping_type )
552555 with self .session_factory () as session , session .begin ():
You can’t perform that action at this time.
0 commit comments