fix data type casting in postgresql