Skip to content

Commit d8e88b5

Browse files
committed
refactor update() method
1 parent 6a56cfc commit d8e88b5

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

simple_query_builder/querybuilder.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -457,18 +457,16 @@ def update(self, table: Union[str, dict], fields: Union[list, dict]):
457457
self.set_error(f"Empty table or fields in {inspect.stack()[0][3]} method")
458458
return self
459459

460-
if isinstance(table, dict):
461-
table = f"`{self._prepare_aliases(table)}`"
462-
elif isinstance(table, str):
463-
table = f"`{table}`"
460+
if isinstance(table, dict) or isinstance(table, str):
461+
table = self._prepare_aliases(table)
464462
else:
465463
self.set_error(f"Incorrect type of table in {inspect.stack()[0][3]} method. Table must be String or Dictionary")
466464
return self
467465

468466
if isinstance(fields, list) or isinstance(fields, dict):
469467
sets = ''
470468
for item in fields:
471-
sets += f" `{item.replace('.', '`.`')}` = ?,"
469+
sets += f" {self._prepare_field(item)} = ?,"
472470
sets = sets.rstrip(',')
473471
else:
474472
self.set_error(f"Incorrect type of fields in {inspect.stack()[0][3]} method. Fields must be String, List or Dictionary")

0 commit comments

Comments
 (0)