Skip to content

Commit

Permalink
Fixed bedset_bedfiles query
Browse files Browse the repository at this point in the history
  • Loading branch information
khoroshevskyi committed Nov 20, 2023
1 parent d411b7d commit 082941f
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions bbconf/bbconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,7 @@ class BedFileBedSetAssociation(SQLModel, table=True):

__table_args__ = {"extend_existing": True}

self.rel_table = BedFileBedSetAssociation
returned_model = BedFileBedSetAssociation.__table__

# this will create a relationship between bedfiles and bedsets, and will have mapping in both tables (bedfiles, bedsets)
Expand Down Expand Up @@ -437,14 +438,22 @@ def select_bedfiles_from_bedset(
results = session.exec(statement).one().bedfiles
bedfile_list = [bedfile.dict() for bedfile in results]
else:
# Probably we can do it in more simple way
with self.bed.backend.session as session:
statement = select(self.BedfileORM.record_identifier).where(
self.BedsetORM.record_identifier == bedset_record_id
self.BedfileORM.id.in_(
select(self.rel_table.bedfile_id).where(
self.rel_table.bedset_id
== select(self.BedsetORM.id).where(
self.BedsetORM.record_identifier == bedset_record_id
)
)
)
)
bedfile_list = session.exec(statement).all()
bedfile_list = [
{"record_identifier": bedset_id} for bedset_id in bedfile_list
]
bedfile_list = [
{"record_identifier": bedset_id} for bedset_id in bedfile_list
]
return bedfile_list

def select_unique(self, table_name: str, column: str = None) -> List[dict]:
Expand Down

0 comments on commit 082941f

Please sign in to comment.