[Dbix-class] PK::Auto and PostgreSQL 7.4.13

Adam Sjøgren asjo at koldfront.dk
Sun Aug 6 02:05:40 CEST 2006


Having just upgraded to the latest Catalyst and DBIx::Class in Debian
unstable, I've run into a slight problem.

When I try to $c->model('DBIC::User)->create(...), I get an error:

 Caught exception in Myapp::Controller::User->create
 "DBIx::Class::ResultSet::create(): Can't get last insert id at
 /var/www/Myapp/script/../lib/Myapp/Controller/User.pm
 line 71"

The strack trace doesn't say much:

 Stack Trace
 Package                  Line  File
 Myapp::Controller::User  71    /var/www/Myapp/lib/Myapp/Controller/User.pm

 68:     }
 69:     else {
 70:         my $new_user=$c->model('DBIC::User')->create({
 71:                            map { $_=>$c->request->param($_) }
 72:                            qw(login password name email address)
 73:                                                      });
 74: 

I've had this working fine previously¹, so I'm wondering whether
DBIx::Class with PK::Auto is known to work correctly with the
(admittedly old²) version of PostgreSQL that I use?

If it is, I must've done something stupid somewhere (it is rather
late...) and I'll go look.
If it isn't, how can I debug further?


If I turn DBIC_TRACE on, I get this output:

 SELECT "me"."id", "me"."created", "me"."login", "me"."password",
  "me"."name", "me"."email", "me"."address" FROM "user" "me" WHERE ( (
  "me"."login" = ? ) ): 'test_me'
 INSERT INTO "user" ("address", "email", "login", "name", "password")
  VALUES (?, ?, ?, ?, ?): '', 'nah at example.invalid', 'test_me', 'Test
  Testesen', 'funk'
 DBD::Pg::db last_insert_id failed: no statement executing
 SELECT COUNT( * ) FROM "user" "me": 
 ROLLBACK

(The first line is from a HTML::Widget-callback that tests to see if
the value in the "login"-field has previously been taken - removing
the callback does not prevent the failure from happening; just tried).


  Best regards,

    Adam


¹ I need to change that code so it works with the new
  DBIx::Class::Schema::Loader, so I haven't tested if that also
  fails, yet.

² I run PostgreSQL 7.4 on the (Debian stable-)server this is going to
  end up on, so that is why I'm not using 8.x.

-- 
 "Subdued flamboyance"                                        Adam Sjøgren
                                                         asjo at koldfront.dk



More information about the Dbix-class mailing list