St. Murphy, Cars, Closets and SQLite 1.13

jk2addict on 2007-04-08T01:36:35

It's been one hell of a week. Aside from all of the server issues at work, everything at home went to shit since yesterday.

Last night, the wife backed into the nephews car when pulling out of the garage. That's bumper #2. Sigh. Then, about 20 minute later, the cloths hanger rod in the closet totally crumbles into a heaping pile of bend metal and pulled out drywall screws.

After sleeping off the frustration, I made a trip to Lowes and installed a bigger better hanger rod.

Once I got back to a computer today, I spent some time trying to help perigrin figure out why Handel tests were failing. In the end, I've managed to find a new way for DBD::SQlite 1.13 to suck ass. It appears that any statement after a PK violation on insert also fails with the same error...from a different line in the C source:

C:\Development\CPAN\Handel>perl test.pl
3DBIx::Class::ResultSet::create(): Error executing 'INSERT INTO cart (id, shopper) VALUES (?, ?)': DBD::SQLite::st execute failed: column id
 is not unique(1) at dbdimp.c line 402 at C:/Development/Perl/584/site/lib/DBIx/Class/Storage/DBI.pm line 879.

DBIx::Class::ResultSet::create(): Error executing 'INSERT INTO cart (id, shopper) VALUES (?, ?)': DBD::SQLite::st execute failed: column id
is not unique(21) at dbdimp.c line 376 at C:/Development/Perl/584/site/lib/DBIx/Class/Storage/DBI.pm line 879.

Here's the DBIC code...I still need to try this with pure DBI:

#!/usr/bin/perl -w
use strict;
use warnings;
use lib 'lib';
use Handel::Cart::Schema;


my $schema = Handel::Cart::Schema->connect('dbi:SQLite:t/var/handel.db');
print $schema->resultset('Carts')->search->count;


## This id already exists in the db
eval {
    $schema->resultset('Carts')->create({
        id => '11111111-1111-1111-1111-111111111111',
        shopper => '11111111-1111-1111-1111-111111111111',
    });
};
print $@;

## This is does not exist in the db
eval {
    $schema->resultset('Carts')->create({
        id => '23411111-1111-1111-1111-111111111111',
        shopper => '11111111-1111-1111-1111-111111111111',
    });
};
print $@;