Fixed CAST type for postgres compatibility.

Signed-off-by: Joseph Rézeau <moodle@rezeau.org>
CONTRIB-4420

Signed-off-by: Joseph Rézeau <moodle@rezeau.org>