Improve efficiency of get_tag_from_name method

This commit is contained in:
Nick Hall 2016-10-29 22:18:07 +01:00
parent ab4e147021
commit 19201eed67

View File

@ -601,11 +601,10 @@ class DBAPI(DbGeneric):
If no such Tag exists, None is returned.
"""
self.dbapi.execute("""select handle from tag where order_by = ?;""",
[self._order_by_tag_key(name)])
self.dbapi.execute("SELECT blob_data FROM tag WHERE name = ?", [name])
row = self.dbapi.fetchone()
if row:
return self.get_tag_from_handle(row[0])
return Tag.create(pickle.loads(row[0]))
return None
def get_number_of(self, obj_key):