[#2917] Improve code generator compatibility with PostgreSQL 8.x by avoiding casting to enum types