Work on redoing orders and related. A lot of code clean up. I think it works pretty well.

This commit is contained in:
Scott Idem
2022-01-19 18:51:24 -05:00
parent 9dbbc26d06
commit d1d3b30ece
8 changed files with 281 additions and 102 deletions

View File

@@ -196,6 +196,13 @@ def sql_update(
fields_string.append('`'+str(key) + '` = :' + str(key))
sql_set = ', '.join(fields_string)
log.debug(sql_set)
if len(sql_set) < 4:
# NOTE: Returning None instead of False since technically the SQL query did not fail. Just that nothing was updated related to that record. I have been returning False if there is a SQL query problem. STI 2022-01-19
# NOTE: A better check might be specifically for 'id' and no other dict values.
log.warning('The SQL SET is unexpectedly short and may not have data. Returning None')
return None
if record_id:
log.info(f'Update record with ID: {record_id}')
@@ -693,7 +700,7 @@ def sql_delete(
sql: str|None = None,
data: dict|None = None
):
log.setLevel(logging.INFO) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
log.debug(locals())
if table_name and (record_id or record_id_random) and not (field_name or field_value or sql or data):
@@ -747,7 +754,6 @@ def sql_delete(
WHERE {sql_where_string}
"""
)
log.debug(sql)
elif sql and not (table_name or record_id or record_id_random or field_name or field_value or data):
# Delete records based on the SQL statement given
log.info('Delete records based on the SQL statement given')
@@ -763,6 +769,8 @@ def sql_delete(
log.debug(sql)
# return False
try:
log.setLevel(logging.DEBUG) # DEBUG, INFO, WARNING, ERROR, EXCEPTION, CRITICAL
if data: