Fix typecast error on postgresql