Skip to content

Commit

Permalink
Cache.update: use Mapping instead of dict when checking attr ty…
Browse files Browse the repository at this point in the history
…pes (+ removed debug print statements)
  • Loading branch information
deeenes committed Sep 24, 2024
1 parent 2000e9b commit 9b94fe3
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions cache_manager/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import datetime
import functools as ft
import collections
from collections.abc import Mapping

from pypath_common import _misc
import platformdirs
Expand Down Expand Up @@ -1082,8 +1083,6 @@ def update(
key=key,
attrs=attrs,
)
print(items)
print(update)
update = update or {}
main_fields = self._table_fields()
main = ', '.join(
Expand All @@ -1110,23 +1109,23 @@ def update(
(
0,
self._quotes(group)
if isinstance(vals, dict)
if isinstance(vals, Mapping)
else 'NULL',
k,
v
)
for group, vals in update.get('attrs', {}).items()
for k, v in (
vals
if isinstance(vals, dict) else
if isinstance(vals, Mapping) else
{group: vals}
).items()
if (
self._sqlite_type(v) == actual_typ.upper()
and k not in main_fields
)
]
print(useattrs)

for keyvar, group, k, v in useattrs:

typ = self._sqlite_type(v)
Expand All @@ -1139,7 +1138,6 @@ def update(
f' AND name = "{k}" AND namespace = {group}'
)
q = f'UPDATE attr_{actual_typ} SET {val} {name_where}'
print(q)
self._execute(q)

# Adding new attr
Expand All @@ -1163,7 +1161,6 @@ def update(
'(id, namespace, keyvar, name, value) '
f'VALUES ({new_values})'
)
print(new_q)
self._execute(new_q)

_log(f'Finished updating attributes')
Expand Down

0 comments on commit 9b94fe3

Please sign in to comment.