Fixes on updates and insert for foreignkeyfields