From 21dd5054e627b3fc50372cfec3b986f78bc7a9f0 Mon Sep 17 00:00:00 2001 From: Andrej730 Date: Tue, 24 Sep 2024 12:35:15 +0500 Subject: [PATCH] ifcopenshell.sql - fix error in by_id method it was fetching some random row from id_map instead of using ifc_id filter --- src/ifcopenshell-python/ifcopenshell/sql.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/ifcopenshell-python/ifcopenshell/sql.py b/src/ifcopenshell-python/ifcopenshell/sql.py index 39340657c7..35cdf43de8 100644 --- a/src/ifcopenshell-python/ifcopenshell/sql.py +++ b/src/ifcopenshell-python/ifcopenshell/sql.py @@ -153,10 +153,11 @@ class sqlite(file): entity = sqlite_entity(id, ifc_class, self) self.entity_cache[id] = entity return entity - self.cursor.execute("SELECT ifc_id, ifc_class FROM id_map LIMIT 1") + self.cursor.execute("SELECT ifc_id, ifc_class FROM id_map WHERE ifc_id = ? LIMIT 1", (id,)) row = self.cursor.fetchone() if row: - self.id_map[row[0]] = row[1] + _, ifc_class = row + self.id_map[id] = ifc_class entity = sqlite_entity(id, ifc_class, self) self.entity_cache[id] = entity return entity