@classmethod
def _sql_column_to_table(cls, name):
    """
        Returns the table in `cls._sql_tables` containing the
        field `name`.

        If `name` corresponds to a primary key column, then
        the primary table (first table) is returned.

        If a table could not be found, a `exceptions.KeyError` is
        raised.
        """
    if name in cls._sql_tables['primary']:
        return cls._sql_primary_table()
    for table_name, fields in cls._sql_tables['tables']:
        if name in fields:
            return table_name
    raise KeyError('Could not find table for %s' % name)
