fix issue with update_all and inner joins with pg

Guys can someone provide feedback on this fix? Thanks in advance
cc @robin850 @rafaelfranca @such
Quite a long line, maybe break out some local variables?