'Check the foreign key columns collected and emit error
messages.'

def _check_foreign_cols(self, join_condition, primary):

    can_sync = False
    foreign_cols = self._gather_columns_with_annotation(join_condition, 'foreign')
    has_foreign = bool(foreign_cols)
    if primary:
        can_sync = bool(self.synchronize_pairs)
    else:
        can_sync = bool(self.secondary_synchronize_pairs)
    if ((self.support_sync and can_sync) or ((not self.support_sync) and has_foreign)):
        return
    if (self.support_sync and has_foreign and (not can_sync)):
        err = ("Could    not    locate    any    simple    equality    expressions    involving    locally    mapped    foreign    key    columns    for    %s    join    condition    '%s'    on    relationship    %s." % (((primary and 'primary') or 'secondary'), join_condition, self.prop))
        err += "        Ensure    that    referencing    columns    are    associated    with    a    ForeignKey    or    ForeignKeyConstraint,    or    are    annotated    in    the    join    condition    with    the    foreign()    annotation.    To    allow    comparison    operators    other    than    '==',    the    relationship    can    be    marked    as    viewonly=True."
        raise sa_exc.ArgumentError(err)
    else:
        err = ("Could    not    locate    any    relevant    foreign    key    columns    for    %s    join    condition    '%s'    on    relationship    %s." % (((primary and 'primary') or 'secondary'), join_condition, self.prop))
        err += '        Ensure    that    referencing    columns    are    associated    with    a    ForeignKey    or    ForeignKeyConstraint,    or    are    annotated    in    the    join    condition    with    the    foreign()    annotation.'
        raise sa_exc.ArgumentError(err)
