Fixed #328. Check if local column is foreign key, if not - use remote column