sql >> Base de Datos >  >> RDS >> PostgreSQL

Error de Postgres con Sinatra/Haml/DataMapper en Heroku

Parece que post_id es de tipo TEXTO en lugar de INTEGER. Para solucionar esto, debe cambiar el tipo de datos. Esto se ha cambiado en la versión 8.3, la versión anterior tiene una conversión implícita. Puede decirle a PostgreSQL que lo haga:

CREATE FUNCTION pg_catalog.text(integer) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int4out($1));';
CREATE CAST (integer AS text) WITH FUNCTION pg_catalog.text(integer) AS IMPLICIT;

CREATE FUNCTION pg_catalog.text(smallint) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int2out($1));';
CREATE CAST (smallint AS text) WITH FUNCTION pg_catalog.text(smallint) AS IMPLICIT;

CREATE FUNCTION pg_catalog.text(bigint) RETURNS text STRICT IMMUTABLE LANGUAGE SQL AS 'SELECT textin(int8out($1));';
CREATE CAST (bigint AS text) WITH FUNCTION pg_catalog.text(bigint) AS IMPLICIT;

Consulte también http://wiki.postgresql.org/wiki/Image :Pg83-implicit-casts.sql