Skip to content

Commit

Permalink
Revert to using ORM with bulk_mappings for session managment in tests"
Browse files Browse the repository at this point in the history
  • Loading branch information
adelavega committed Aug 3, 2023
1 parent 405fc0b commit b859764
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions bids/layout/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,9 @@ def __call__(self, layout):
all_bfs, all_tag_dicts = self._index_dir(self._layout._root, self._config)

self.session.bulk_save_objects(all_bfs)
self.session.bulk_insert_mappings(Tag, all_tag_dicts)
self.session.commit()

# Use SQLAlchemy Core to make bulk inserts for Tags
if all_tag_dicts:
self.session.execute(Tag.__table__.insert(), all_tag_dicts)

if self.index_metadata:
self._index_metadata()

Expand Down Expand Up @@ -490,8 +487,5 @@ def create_association_pair(src, dst, kind, kind2=None):
all_tag_dicts.append(tag)

self.session.bulk_save_objects(all_objs)
self.session.commit()

# Use SQLAlchemy Core to make bulk inserts
if all_tag_dicts:
self.session.execute(Tag.__table__.insert(), all_tag_dicts)
self.session.bulk_insert_mappings(Tag, all_tag_dicts)
self.session.commit()

0 comments on commit b859764

Please sign in to comment.