def updateTable(tableObj, bodyFromRequest, updateBool=False):
  # This is to handle the CREATE and UPDATE methods of CRUD
  # Args:
  #  tableObj => ProtoType of the table to be updated
  #  bodyFromRequest => {
  #    updateParams => A dict containing the fields to be changed in the table,
  #    queryParams => A dict containing the tables to query
  #  }
  #  updateBool  => Set to False, means that you are creating an entry,
  #                 True, means an update 
  #  Note:  If updateBool is set, you MUST provide an 'id' in 'updateParams'
  if not (tableObj and bodyFromRequest): 
    return None # Handle this mishap later

  errorID = -1 
  changeCount = duplicatesCount = 0
  if not isinstance(bodyFromRequest, dict):
    print("Arg 2 must be a dictionary")
    return errorID, changeCount, duplicatesCount

  allowedKeys = None
  if not updateBool:
    objectToChange = tableObj()
    updateParams = bodyFromRequest
    allowedKeys = getUserMutableFilters(objectToChange)

  else:
    queryParams = bodyFromRequest.get('queryParams', None)
    if not isinstance(queryParams, dict):
      print('Expecting a query body passed in as a dict')
      return errorID, changeCount, duplicatesCount

    elif tableObj.objects.count() < 1: # Journey cut short if not even a single item exists
      return errorID, changeCount, duplicatesCount

    else:
      allowedFilters = captureUserMutableAttrsFromObj(
                                tableObj.objects.first(), queryParams)

      objMatch = tableObj.objects.filter(*allowedFilters)

      if not objMatch:
        print(
           'Error: Could not find items that match query params', queryParams)
        return errorID, changeCount, duplicatesCount
      else:
        allowedKeys = getUserMutableFilters(objMatch[0])
        if objMatch.count() == 1: # Just one item can be individually inspected
            objectToChange = objMatch[0]
        else:
            objectToChange = objMatch

        updateParams = bodyFromRequest.get('updateParams', None)
        if updateParams is None:
          updateParams = {}

  cherryPickedAttrs = dict(
    (str(k), updateParams[k]) for k in updateParams if isMutableAttr(k) and k in allowedKeys
  )

  if isCallableAttr(objectToChange, 'update'):
    objectToChange.update(**cherryPickedAttrs)
    changeCount = objectToChange.count()
    return changeCount, changeCount, -1
  else:
    for attr in cherryPickedAttrs:
       attr = str(attr) # To handle the initial unicode form eg u'key' yet desired is 'key'

       attrValue = updateParams.get(attr)
       if updateBool: 
          origValue = getattr(objectToChange, attr, None)
          if (attrValue == origValue): 
             duplicatesCount += 1
             continue

       setattr(objectToChange, attr, attrValue)
       changeCount += 1

    if not changeCount: 
      return objectToChange.id, changeCount, duplicatesCount
    else:
      # Let's get that data written to memory
      savedBoolean = saveToMemory(objectToChange)

      if savedBoolean:
        return objectToChange.id, changeCount, duplicatesCount
      else:
        return errorID, -1, -1
dataset/ETHPy150Open odeke-em/restAssured/api/crudAPI.py/updateTable/original