[Dbix-class] prepending Pg schema name in queries

Peter Shangov pshangov at yahoo.com
Wed Jul 7 10:22:55 GMT 2010


Hi, 

I have the following schema class to access the 'user' table from the 
'materials' schema in a PostgreSQL database:

package ADP::Schema::Materials::Result::User;
use base 'DBIx::Class::Core';
__PACKAGE__->table("materials.user");
...

Later on, the following code:

my $schema = ADP::Schema::Materials->connect( ... );
my $rs = $schema->resultset('User')->all;

produces an error:

DBI Exception: DBD::Pg::st execute failed: ERROR:  column notation .user_id 
applied to type name, which is not a composite type
LINE 1: SELECT me.user_id, me.username, me.name, me.name_local, me.e...
               ^ [for Statement "SELECT me.user_id, me.username, me.name, 
me.name_local, me.email, me.active, me.cms2_id, me.cms3_id, me.wordpress_id FROM
user me"] at C:/strawberry/perl/site/lib/DBIx/Class/Schema.pm line 1026

This error is due to the fact that 'user' is a reserved word and "SELECT ... 
FROM user" fails. How can I force DBIx::Class to prepend the schema name to the 
table in the query, to get "SELECT ... FROM materials.user"?

Regards,




More information about the DBIx-Class mailing list