Subject: | Invalid SQL being generated |
Most of my tables have an integer primary key, Catalyst::Plugin::AutoCRUD is attempting to
pull individual values to populate the autogenerated tables with SQL that has:
( LOWER(me.foo_id) = LOWER(?) )
Of course, LOWER() doesn't make sense when operating on an integer, and Postgres
complains:
[error] FooDB::Foo::item(): DBI Exception: DBD::Pg::st execute failed: ERROR: function
lower(integer) does not exist
This may be a change in postgres as of 8.3 (as some string functions accepted non-string
data types in past versions if they could be stringified).
In postgres, this can be worked around by restoring (some of) the old behavior:
CREATE FUNCTION text_to_int(TEXT) RETURNS INT4 AS '
SELECT int4in(textout($1));
' LANGUAGE SQL STRICT IMMUTABLE;
CREATE CAST (TEXT AS INT4)
WITH FUNCTION text_to_int(TEXT)
AS IMPLICIT;