code: def get_pks_from_query(self, query):
          
          where = query.where
          sql = None
          if where.connector == 'AND' and not where.negated and len(where.children) == 1:
              # simple cases are optimized, especially because a suboptimal
              # nested query based on the same table is not allowed by SF
              child = where.children[0]
              if (child.lookup_name in ('exact', 'in') and child.lhs.target.column == 'Id'
                      and not child.bilateral_transforms and child.lhs.target.model is self.query.model):
                  pks = child.rhs
                  if child.lookup_name == 'exact':
                      assert isinstance(pks, text_type)
                      return [pks]
                  # lookup_name 'in'
                  assert not child.bilateral_transforms
                  if isinstance(pks, (tuple, list)):
                      return pks
                  if DJANGO_111_PLUS:
                      assert isinstance(pks, Query) and type(pks).__name__ == 'SalesforceQuery'
                      # # alternative solution:
                      # return list(salesforce.backend.query.SalesforceQuerySet(pk.model, query=pk, using=pk._db))
  
                      sql, params = pks.get_compiler('salesforce').as_sql()
                  else:
                      assert isinstance(pks, salesforce.backend.query.SalesforceQuerySet)
                      return [x.pk for x in pks]
          if not sql:
              # a subquery is necessary in this case
              where_sql, params = where.as_sql(query.get_compiler('salesforce'), self.db.connection)
              sql = "SELECT Id FROM {} WHERE {}".format(query.model._meta.db_table, where_sql)
          with self.db.cursor() as cur:
              cur.execute(sql, params)
              assert len(cur.description) == 1 and cur.description[0][0] == 'Id'
              return [x[0] for x in cur]
docs: Prepare primary keys for update and delete queries