[Catalyst] Trouble inserting data after migrate database from SQLite to My SQL

Steve steve at matsch.com
Tue Nov 10 14:05:56 GMT 2009


Jordi Amorós wrote:
> Hi all,
>
> I'm developing a little web application (a remote lab that works with
> Catalyst+LabView). Until now I was using SQLite, but due to new
> requirements I've had to migrate the database.
>
> I've created a new model:
> perl script/ilabrs_create.pl model DB DBIC::Schema ilabrs::Schema
> create=static components=TimeStamp,EncodedColumn dbi:mysql:ilabrs
>
> and then, after restarting the server all seemed to work. Actually,
> list, edit and erase from the database is working fine. But when I want
> to add data, it doesn't work.
>
> The problem appears when an id it's not provided. If I'm not wrong,
> "my $exp = $c->model('DB::Activitats')-> find_or_new({id=> $id});"
> should solve that. But: "$c->log->debug("Experiment ID:".$exp->id);",
> prints nothing.
>
> I'm absolutely clueless. I've tried to split de edit function in two:
> -one to actually edit (my $exp = $c->model('DB::Activitats')->
> find({id=> $id});) which still works properly.
>
> -and a second one to add (my $exp = $c->model('DB::Activitats')->
> new({});) which doesn't because $exp->id is empty and 
> $exp->update_or_insert;
> cause an exception:
>
> DBI Exception: DBD::mysql::st execute failed: Column 'id' cannot be
> null...
>
> Any suggestion, idea, clue... will be welcome.
>
> Thanks,
>
> Jordi
>
>
>
>
>
>  
>
>
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/
>
>
>   
Is your 'id' set to auto-increment???  What data type is it?  I usually 
set the 'id' to auto-increment, and set it as an integer.  I would also 
recommend using DBIC_TRACE=1 from the command line if possible to get a 
better description of the actual problem.

Steve



More information about the Catalyst mailing list