Skip Menu |
 

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 67775
Status: rejected
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: glasswalk3r [...] yahoo.com.br
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: cannot use columns accessor of a ResultSet class with find method
Date: Tue, 26 Apr 2011 13:33:46 -0700 (PDT)
To: "bug-DBIx-Class [...] rt.cpan.org" <bug-DBIx-Class [...] rt.cpan.org>
From: "Alceu R. de Freitas Jr." <glasswalk3r [...] yahoo.com.br>
Download (untitled) / with headers
text/plain 3.5k
Greetings, I'm a begginer with DBIx::Class and created the following class for studying: package DAO::Siebel::Result::Contact; use base qw/DBIx::Class::Core/; __PACKAGE__->table('SIEBEL.S_CONTACT'); __PACKAGE__->add_columns(     fst_name => {         data_type         => 'varchar',         size              => 50,         is_nullable       => 0,         is_auto_increment => 0,         default_value     => ''     },     last_name => {         data_type         => 'varchar',         size              => 50,         is_nullable       => 0,         is_auto_increment => 0,         default_value     => ''     },     regl_stat_cd => {         accessor          => 'state',         data_type         => 'varchar',         size              => 30,         is_nullable       => 1,         is_auto_increment => 0,         default_value     => ''     },     longitude => {         accessor          => 'rcn',         data_type         => 'integer',         size              => 22,         is_nullable       => 1,         is_auto_increment => 0,         default_value     => ''     },     x_big_status => {         accessor          => 'status',         data_type         => 'varchar',         size              => 30,         is_nullable       => 1,         is_auto_increment => 0,         default_value     => ''     },     con_cd => {         accessor          => 'type',         data_type         => 'integer',         size              => 22,         is_nullable       => 1,         is_auto_increment => 0,         default_value     => ''     } ); Then I used the following code to test it: use warnings; use strict; use lib 'C:\temp'; use DAO::Siebel; my %extra_attributes = ( limit_dialect => 'RowNum' ); my $schema = DAO::Siebel->connect( 'dbi:ODBC:DEV', 'user', 'password',     \%extra_attributes ); my $state = 'PR'; my $cr_num = 11778; my $phy =   $schema->resultset('Contact')->find({ state => $state, longitude => $cr_num }); print $phy->state, $phy->fst_name(), ' ', $phy->last_name(), ', ', $phy->type(), ', ',   $phy->status(), "\n"; This code fails with the following message: DBIx::Class::ResultSet::find(): DBI Exception: DBD::ODBC::db prepare_cached failed: [Microsoft][ODBC driver for Oracle][Oracle]ORA-00904: "ME"."STATE": invalid identifier (SQL-42S22) [for Statement "SELCT me.fst_name, me.last_name, me.regl_stat_cd, me.longitude, me.x_big_status, me.con_cd FROM SIEBEL.S_CONTACT me WHERE ( ( me.longitude = ? AND me.state = ? ) )"] at C:\temp\test.pl line 19 DBIx::Class is querying the database with a invalid column name for table SIEBEL.S_CONTACT. But if I change the find method to use the real name of the column: my $phy =   $schema->resultset('Contact')->find({ regl_stat_cd => $state, longitude => $cr_num }); The code works as expected, even the next line that uses the accessor "state" instead of "regl_stat_cd". Is this behaviour expected? Or it is a bug? I'm using a Windows XP box with Strawberry Perl: This is perl 5, version 12, subversion 2 (v5.12.2) built for MSWin32-x86-multi-thread And querying a Oracle 9i database with Microsoft ODBC. Regards, Alceu
Download (untitled) / with headers
text/plain 419b
Yes this is a documented caveat. Currently our search-specification tools (SQL::abstract) are not mature enough to offer introspection of the structure, and as such it is very hard to figure out what is a column and what is an alias/accessor and needs to be substituted for a "real" column name. I am rejecting this ticket as "wontfix" as the resolution of this issue is nowhere near to being solved in the short term.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.