Subject: | DBIx::Class problem (probably) |
Date: | Fri, 03 Jul 2015 16:42:00 +0000 |
To: | bug-DBIx-Class [...] rt.cpan.org |
From: | Mariano Spadaccini <spadacciniweb [...] gmail.com> |
I have written a sotware and I want move this software on a more power
machine... but there are some problems and I do not understand if they are
related to DBIx::Class.
I have created many packeges (as Agent.pm) from the command:
Show quoted text
> cd lib ; dbicdump -o debug=1 -o components='[qw(Helper::Row::ToJSON
InflateColumn::Serializer InflateColumn::DateTime
Helper::ResultSet::SetOperations)]' MySchema::Master
'dbi:mysql:dbname=mydb' root ; cd ..
The documentation created for the package Agent.pm is:
Show quoted text> perldoc Agent
Agent(3) User Contributed Perl Documentation
Agent(3)
NAME
MySchema::Master::Result::Agent
COMPONENTS LOADED
· DBIx::Class::Helper::Row::ToJSON
· DBIx::Class::InflateColumn::Serializer
· DBIx::Class::InflateColumn::DateTime
· DBIx::Class::Helper::ResultSet::SetOperations
TABLE: "agent"
ACCESSORS
id
data_type: 'integer'
extra: {unsigned => 1}
is_auto_increment: 1
is_nullable: 0
profilo
data_type: 'enum'
default_value: 'Manutentore'
extra: {list =>
["Manutentore","Amministrativo","Admin","AdminExt","Superadmin","Ente","AmExt","Ispettore"]}
is_nullable: 1
id_appalto
data_type: 'integer'
extra: {unsigned => 1}
is_nullable: 1
user
data_type: 'varchar'
is_nullable: 1
size: 15
pass
data_type: 'varchar'
is_nullable: 0
size: 255
disabled
data_type: 'tinyint'
default_value: 0
is_nullable: 1
note
data_type: 'text'
is_nullable: 1
creation
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: '0000-00-00 00:00:00'
is_nullable: 0
last_login
data_type: 'datetime'
datetime_undef_if_invalid: 1
is_nullable: 1
ts
data_type: 'timestamp'
datetime_undef_if_invalid: 1
default_value: current_timestamp
is_nullable: 0
PRIMARY KEY
· "id"
UNIQUE CONSTRAINTS
"idx_user"
· "user"
RELATIONS
controlloes
Type: has_many
Related object: MySchema::Master::Result::Controllo
ispeziones
Type: has_many
Related object: MySchema::Master::Result::Ispezione
perl v5.18.2 2015-05-26
Agent(3)
At the begin, in main package, I write the code:
...
sub master () {
$Master ||= MySchema::Master->connect;
return $Master;
}
...
So, master->resultset('Agent') is the Agent from MySQL table remapped as
resultset Agent. I can used the DBIx::Class::ResultSet methods as
search_rs, ... without problems.
So I can write:
my ($hashed_passwd) = 'a_complicated_salted_password';
my $agent = master->resultset('Agent')->search({
user => params->{login},
pass => $hashed_passwd,
})->single;
if ($agent) {
return Dumper($agent);
} else {
return 'hard error';
}
and I see the object $agent.
I can also write:
if ($agent) {
return Dumper($agent->get_columns);
} else {
return 'hard error';
}
(with 's' because I have loaded DBIx::Class::Row) and the output is:
$VAR1 = 'pass';
$VAR2 = 'a_complicated_salted_password';
$VAR3 = 'creation';
$VAR4 = '0000-00-00 00:00:00';
$VAR5 = 'note';
$VAR6 = undef;
$VAR7 = 'id';
$VAR8 = '28';
$VAR9 = 'id_appalto';
$VAR10 = undef;
$VAR11 = 'user';
$VAR12 = 'superadmin';
$VAR13 = 'profilo';
$VAR14 = 'Superadmin';
$VAR15 = 'last_login';
$VAR16 = '2015-06-24 11:31:39';
$VAR17 = 'ts';
$VAR18 = '2015-06-25 18:17:03';
$VAR19 = 'disabled';
$VAR20 = '0';
Good. It look likes there is no problem.
But if I write this:
if ($agent) {
return Dumper($agent->profilo);
} else {
return 'hard error';
}
I get this error:
Can't call method "columns" on an undefined value at
/usr/local/share/perl/5.18.2/DBIx/Class/ResultSet.pm line 3527, <DATA> line
16.
On old machine, this code return the profile 'Superadmin'.
I have replicated this software with many perl distributions (perlbrew)
perl-5.16.3
perl-5.18.4
perl-5.20.2
perl-5.22.0
and I have always the same error.
The software runs correctly on two machines:
- Ubuntu 14.04, perl v5.18.2, DBIx-Class from CPAN
- Ubuntu 12.04, perl v5.14.2, DBIx-Class-0.08250 (build from source)
Have you any idea?
Thanks for any tips