Skip to content

Commit

Permalink
Finished Cache.update method
Browse files Browse the repository at this point in the history
finished writing the type checks comprehension
  • Loading branch information
npalacioescat committed Jun 4, 2024
1 parent c9d2c1a commit a27b358
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions cache_manager/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,15 +376,17 @@ def update(

_log(f'Updating attributes in attr_{actual_typ}')

main = ', '.join(
values = ', '.join(
f'{k} = {self._quotes(v, main_fields[k])}'
for k, v in update.items() if k not in main_fields and
for k, v in update.items()
if (k not in main_fields and
str(type(v)) == actual_typ)
)
ids = [it.id for it in items()]
_log(f'Updating {len(ids)} items')

where = f'WHERE id IN ({", ".join(ids)})'

q = f'UPDATE main SET ({main}) {where}'
q = f'UPDATE main SET ({values}) {where}'

self._execute(q)
2 changes: 1 addition & 1 deletion cache_manager/_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class CacheItem:
Cache item class, stores a single cache item information.
"""

def __init__(# TODO:add filename
def __init__(
self,
key,
version: int = 1,
Expand Down

0 comments on commit a27b358

Please sign in to comment.