Working on products and carts
This commit is contained in:
@@ -132,20 +132,20 @@ def sql_update(sql:str|None=None, data:dict|None=None, table_name:str|None=None,
|
||||
sql_set = ', '.join(fields_string)
|
||||
|
||||
if record_id:
|
||||
log.info('Update record with ID')
|
||||
log.info(f'Update record with ID: {record_id}')
|
||||
data['id'] = record_id
|
||||
sql = 'UPDATE `'+table_name+'` SET '+ sql_set + ' WHERE id = :id'
|
||||
elif record_id_random:
|
||||
log.info('Update record with ID random')
|
||||
log.info(f'Update record with ID random: {record_id_random}')
|
||||
data['id_random'] = record_id_random
|
||||
sql = 'UPDATE `'+table_name+'` SET '+ sql_set + ' WHERE id_random = :id_random'
|
||||
elif 'id' in data:
|
||||
log.info('Update record with ID')
|
||||
log.info(f"Update record with ID in data dict: {data['id']}")
|
||||
sql = 'UPDATE `'+table_name+'` SET '+ sql_set + ' WHERE id = :id'
|
||||
elif 'id_random' in data:
|
||||
# NOTE: For now it is not possible to update the id_random when supplying the id_random as the primary key for a record.
|
||||
# NOTE: In the future I can use record_id_random=True as a special case SQL UPDATE.
|
||||
log.info('Update record with ID random')
|
||||
log.info(f"Update record with ID in data dict: {data['id_random']}")
|
||||
sql = 'UPDATE `'+table_name+'` SET '+ sql_set + ' WHERE id_random = :id_random'
|
||||
else:
|
||||
log.warning('Something was missing from the sql_update function call.')
|
||||
|
||||
Reference in New Issue
Block a user