From b859764b51a5f9ced68863d5d733899d5e85db48 Mon Sep 17 00:00:00 2001 From: Alejandro de la Vega Date: Thu, 3 Aug 2023 17:11:54 -0500 Subject: [PATCH] Revert to using ORM with bulk_mappings for session managment in tests" --- bids/layout/index.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/bids/layout/index.py b/bids/layout/index.py index 94392a7e..741e0bfd 100644 --- a/bids/layout/index.py +++ b/bids/layout/index.py @@ -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() @@ -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() \ No newline at end of file