docs: def get_relations(self, cursor, table_name):
          """
          Returns a dictionary of {field_index: (field_index_other_table, other_table)}
          representing all relationships to the given table. Indexes are 0-based.
          """
          # pylint:disable=global-statement,too-many-locals,too-many-nested-blocks,unused-argument
          def table2model(table_name):
              return SfProtectName(table_name).title().replace(' ', '').replace('-', '')
          global last_introspected_model, last_read_only, last_refs
          global last_with_important_related_name  # pylint:disable=invalid-name
          result = {}
          reverse = {}
          last_with_important_related_name = []
          last_read_only = {}
          last_refs = {}
          for _, field in enumerate(self.table_description_cache(table_name)['fields']):
              if field['type'] == 'reference' and field['referenceTo']:
                  reference_to_name = SfProtectName(field['referenceTo'][0])
                  relationship_order = field['relationshipOrder']
                  if relationship_order is None:
                      relationship_tmp = set()
                      for rel in field['referenceTo']:
                          for chld in self.table_description_cache(rel)['childRelationships']:
                              if chld['childSObject'] == table_name and chld['field'] == field['name']:
                                  relationship_tmp.add(chld['cascadeDelete'])
                      assert len(relationship_tmp) <= 1
                      if True in relationship_tmp:
                          relationship_order = '*'
                  last_refs[field['name']] = (field['referenceTo'], relationship_order)
                  result[field['name']] = ('Id', reference_to_name)
                  reverse.setdefault(reference_to_name, []).append(field['name'])
                  if not field['updateable'] or not field['createable']:
                      sf_read_only = (0 if field['updateable'] else 1) | (0 if field['createable'] else 2)
                      # use symbolic names NOT_UPDATEABLE, NON_CREATABLE, READ_ONLY instead of 1, 2, 3
                      last_read_only[field['name']] = reverse_models_names[sf_read_only]
          for ref, ilist in reverse.items():
              # Example of back_collision: a class Aaa has a ForeignKey to a class
              # Bbb and the class Bbb has any field with the name 'aaa'.
              back_name_collisions = [
                  x['name'] for x in self.table_description_cache(ref)['fields']
                  if re.sub('Id$' if x['type'] == 'reference' else '', '',
                            re.sub('__c$', '', x['name'])
                            ).replace('_', '').lower() == table2model(table_name).lower()]
              # add `related_name` only if necessary
              if len(ilist) > 1 or back_name_collisions:
                  last_with_important_related_name.extend(ilist)
          last_introspected_model = table2model(table_name)
          return result