New CRUD PATCH endpoint

This commit is contained in:
Scott Idem
2022-11-28 19:40:57 -05:00
parent 856e2a2891
commit 188947ecad
3 changed files with 184 additions and 83 deletions

View File

@@ -351,15 +351,22 @@ def sql_update(
else:
log.debug(result_update)
log.debug(f'rowcount = {result_update.rowcount}; lastrowid = {result_update.lastrowid}')
if result_update.rowcount >= 1 and result_update.lastrowid == 0: # update with no change
log.info(f'Updated {result_update.rowcount} records (with no changes?)') # With SQL UPDATE this record may have actually changed
if result_update.rowcount >= 1 and result_update.lastrowid == 0: # one record updated
log.info(f'One record was found and updated (changes unknown). Returning True') # With SQL UPDATE this record may have actually changed
return True
elif result_update.rowcount > 1 and result_update.lastrowid == 0: # multiple records updated
log.info(f'Multiple records ({result_update.rowcount}) were found and updated. Returning True')
return True
elif result_update.rowcount == 0 and result_update.lastrowid == 0: # no records found to update (ID probably not found)
log.info('No record(s) found to update. The ID was probably not found. Returning None')
return None
elif result_update.rowcount == 2 and result_update.lastrowid > 0: # update with change
log.warning('Should we be here???')
log.info('Update record with changes')
record_id = result_update.lastrowid
return record_id
else:
log.info('Unknown or unexpected SQL UPDATE response? Returning None')
log.debug(result_update)
log.debug(vars(result_update))
log.debug(dir(result_update))