[Dbix-class] ENUM values from MySQL using the column_info()

Jess Robinson castaway at desert-island.demon.co.uk
Fri May 12 13:43:59 CEST 2006



On Fri, 12 May 2006, Zbigniew Lukasiak wrote:

> On 5/12/06, Carl Franks <fireartist at gmail.com> wrote:
>> As far as I know, DBIx::Class doesn't make any effort to try to be
>> case-insensitive, but if your database is, then DBIx::Class may appear
>> to be case-insensitive.
>
> I don't know how much conscious effor there is but if I have a table
> with two columns with names differing only by case:
>
> test=# select * from casecheck;
> id | name | NAME
> ----+------+------
>  1 | aaa  | AAA
> (1 row)
>
> (this is Pg)
>
> and I define DBIC class columns with the same case:
>
> __PACKAGE__->add_columns(qw/id name NAME/);
>
>
> Then when I retrieve the record and print the values in it's columns:
> my $record = $schema->resultset( 'Casecheck' ) -> find ( 1 );
> print "record->name: ", $record->name, "\n";
> print "record->NAME: ", $record->NAME, "\n";
>
> I get:
>
> record->name: aaa
> record->NAME: aaa
>
> While I would expect the last line to be: record->NAME: AAA
>
> Summing up - the database is casesensitive, but in DBIC is not (in this case:).
>

No, that's DBIC throwing : SELECT me.name, me.NAME from Casecheck at your 
database, and expecting it to do something sane. Apparently Pg doesnt, 
you'd need to turn on quoting to get that to work..

DBIC's column name accessors ARE case sensitive, its just that Pg is 
returning the contents of the "name" column both times.. try it on the 
pgsql util?

To fix: $schema->storage->quote_char("'") .. or whatever Pg wants it to 
be..

I cant see this being a huge problem, as who names their columns the same 
but in different case anyway??

Jess




More information about the Dbix-class mailing list