[Dbix-class] SQLite problem (cannot update in iterator loop)

Brandon Black blblack at gmail.com
Thu Jan 19 18:05:57 CET 2006


On 1/19/06, Daisuke Murase <typester at cpan.org> wrote:
> Hi all.
>
> I just found strange behavior DBIC with SQLite3.
>
> Here is sample script, and it's does not work on my PC.
>
>     use strict;
>     use warnings;
>
>     use DBIx::Class::Loader;
>
>     DBIx::Class::Loader->new(
>         dsn       => 'dbi:SQLite:dbic_test.db',
>         namespace => 'DBIC',
>     );
>
>     for ( 1 .. 100 ) {
>         DBIC::Test->create( { text => "text $_", } );
>     }
>
>     my $test_ite = DBIC::Test->search;
>     while ( my $test = $test_ite->next ) {
>         $test->text( $test->text . ' updated' );
>         $test->update;
>     }
>
>
> This script shows following error:
>
>     DBD::SQLite::st execute failed: database table is locked(1) at
>     dbdimp.c line 398 at
>     /usr/local/share/perl/5.8.4/DBIx/Class/Storage/DBI.pm line 187.
>     Use of uninitialized value in numeric eq (==) at
>     /usr/local/share/perl/5.8.4/DBIx/Class/Row.pm line 116.  Can't
>     update DBIC::Test=HASH(0x85a8c3c): row not found at dbic_test.pl
>     line 20
>
>
> But It's work fine using:
>
>     my @tests = DBIC::Test->search;
>     for my $test (@tests) { ... }
>
> instead of iterator.
>
>
> dbic_test.db's SQL is here:
>
>     CREATE TABLE test (
>            id INTEGER NOT NULL PRIMARY KEY,
>            text TEXT
>     );
>
>
> Any ideas ?
>

I get the same error trying your test on Loader 0.13 and DBIx::Class
0.4999_02.  I also tried eliminating Loader to make sure it wasn't the
problem, by defining the classes manually with:

------------------------------

{
    package DBIC;
    use base qw/DBIx::Class/;
    __PACKAGE__->load_components(qw/PK::Auto::SQLite Core DB/);
    __PACKAGE__->connection($dsn);
}

{
    package DBIC::Test;
    use base qw/ DBIC /;
    DBIC::Test->table('test');
    DBIC::Test->add_columns('id', 'text');
    DBIC::Test->set_primary_key('id');
}

-----------------------

Still got the same error (with different line numbers since I'm using
0.4999_02):

DBD::SQLite::st execute failed: database table is locked(1) at
dbdimp.c line 398 at
/usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Storage/DBI.pm line 241.
Use of uninitialized value in numeric eq (==) at
/usr/lib/perl5/site_perl/5.8.5/DBIx/Class/Row.pm line 94.
Can't update DBIC::Test=HASH(0x84e578c): row not found at
./sqlite_fail.pl line 58

I haven't quite figured out the source of the problem yet though...

-- Brandon



More information about the Dbix-class mailing list