Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

DBIx::Class problem (probably)

by spadacciniweb (Curate)
on Jun 25, 2015 at 18:02 UTC ( [id://1131992]=perlquestion: print w/replies, xml ) Need Help??

spadacciniweb has asked for the wisdom of the Perl Monks concerning the following question:

I have written a sotware and today I have moved this software on a more power machine...
but there are some problems and I do not understand if they are related to Perl. In a point I've written this:
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->get_columns); } else { return 'hard error'; }
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';
It look likes there is no problem.
But if I write this:
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->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, so 'Superadmin'.
Have you any idea?
Thank you

($_="nzz ojjdloobnf jjt tqqbebd77jojxfc")=~y~wb-zg2-5c96-8~aa-z0-9~s=~s~~~s;$_=~y~5-8~fuck~;print

Replies are listed 'Best First'.
Re: DBIx::Class problem (probably)
by Athanasius (Archbishop) on Jun 26, 2015 at 02:08 UTC

    Hello spadacciniweb,

    You haven’t given us enough information.

    From the error, it appears that $agent is an instance of DBIx::Class::ResultSet. However, the methods get_columns and profilo are not listed in the documentation for that module. The closest to the first is the get_column method (note: singular, not plural), and there is nothing corresponding to profilo. So, what is $agent? Likewise, in the line:

    my $agent = master->resultset('Agent')->search({

    what is master? From the syntax, it should be a reference of some kind, but references aren’t usually represented as barewords. Are you running under use strict;?

    Please see How do I post a question effectively? and The SSCCE.

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

      Hello Athanasius, your request is reasonable... I hate the person who do not work to make understandable the code.
      So I try and hope I have made better work.
      I have created many packeges (as Agent.pm) from the command:
      cd lib ; dbicdump -o debug=1 -o components='[qw(Helper::Row::ToJSON In +flateColumn::Serializer InflateColumn::DateTime Helper::ResultSet::Se +tOperations)]' MySchema::Master 'dbi:mysql:dbname=mydb' root ; cd ..
      The documentation created for the package Agent.pm is:
      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","Admi +nExt","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 other package, I write the code:
      ... sub master () { $Master ||= MySchema::Master->connect; return $Master; } ...
      So, master->resultset('Agent') is the Agent MySQL table as Agent resultset. I can used the DBIx::Class::ResultSet methods as search_rs, ... without problems.
      In my initial code posted, I can:
      return $agent;
      or
      return $agent->get_columns;
      (with 's' because I have loaded DBIx::Class::Row)
      but I have the error already posted if in my code write
      return $agent->profilo
      or
      $agent->update({ last_login => \ " NOW()" });
      Why is there an error?
      And, more important, why the same code not show error in old machine (and it is right)?

      I do not understand. :-(
      Thank you for any tips

      ($_="nzz ojjdloobnf jjt tqqbebd77jojxfc")=~y~wb-zg2-5c96-8~aa-z0-9~s=~s~~~s;$_=~y~5-8~fuck~;print
        I have resolved the problem, but I do not know the origin.
        However, the steps are:
        - change CPAN repository (CPAN> o conf urllist) - rebuild CPAN modules (CPAN> upgrade)

        Probably the upgrade of DBIx::Class::* modules has fixed the problem.


        Update: from today onwards, I use perlbrew

        ($_="nzz ojjdloobnf jjt tqqbebd77jojxfc")=~y~wb-zg2-5c96-8~aa-z0-9~s=~s~~~s;$_=~y~5-8~fuck~;print

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://1131992]
Approved by planetscape
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (5)
As of 2024-04-25 19:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found