Implement #1579 Default to primary key when adding relation.

Signed-off-by: Hugues Peccatte <hugues.peccatte@gmail.com>
Merge remote-tracking branch 'Tithugues/r1579_master'