Fixed a bug that on dup sql causes errors