Skip to content

Commit

Permalink
Fixed type checking in Cache.update when updating attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
npalacioescat committed Sep 17, 2024
1 parent 6976357 commit 1409a9d
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions cache_manager/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def search(
Example:
>>> cache = cm.Cache('./')
>>> it = cache.create('foo')
>>> cache.search(uri='foo)
>>> cache.search(uri='foo')
[CacheItem[foo V:1 UNINITIALIZED]]
"""

Expand Down Expand Up @@ -1106,15 +1106,26 @@ def update(

for k, v in update.get('attrs', {}).items():

typ = type(v).__name__
typ = self._sqlite_type(v)
print(v, typ, actual_typ)

if k not in main_fields and typ == actual_typ:
if k not in main_fields and typ == actual_typ.upper():
print('HELOOOOO')

val = f'value = {self._quotes(v, TYPES[typ])}'
# Updating current attr
val = f'value = {self._quotes(v, typ)}'
name_where = where + f' AND name = {self._quotes(k)}'
q = f'UPDATE attr_{actual_typ} SET {val} {name_where}'
self._execute(q)

# Adding new attr
q = f'SELECT id FROM attr_{actual_typ} {name_where}'
self._execute(q)
_ids = [i[0] for i in self.cur.fetchall()]
print(_ids)



_log(f'Finished updating attributes')


Expand Down

0 comments on commit 1409a9d

Please sign in to comment.