FAQ
First of all hello people of the list!

I am working on my first Catalyst app and need some help updating an
entry from my database.

$c->stash( users_rs => $c->model('DB::Tech'));
my $user = $c->stash->{users_rs}->find({ id => $userid });
die "No such user: $userid\n" if (!$user);
$c->stash(user => $user);
$c->log->debug('Before update');
$user->update({
id => $username,
firstname => $fname,
lastname => $lname,
email => $email,
phone => $phone,
});
$c->log->debug('After update');

In the debug output from Catalyst I can see where the "Before update"
gets printed but fails with no error that I can see during the update.
Any help or advice in this matter would be greatly appreciated.

Search Discussions

  • Rohan M at Apr 3, 2011 at 6:44 am
    Hi Adam,

    Did you try putting result-set in the variable rather than directly putting
    it into stash?

    my $user = $c->model('DB::Tech')->find({id => $userid});
    $user->update({ id => $username,
    firstname => $fname,
    lastname => $lname,
    email => $email,
    phone => $phone,});

    Try this and let us know
    On Sun, Apr 3, 2011 at 12:07 AM, Adam Jimerson wrote:

    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    First of all hello people of the list!

    I am working on my first Catalyst app and need some help updating an
    entry from my database.

    $c->stash( users_rs => $c->model('DB::Tech'));
    my $user = $c->stash->{users_rs}->find({ id => $userid });
    die "No such user: $userid\n" if (!$user);
    $c->stash(user => $user);
    $c->log->debug('Before update');
    $user->update({
    id => $username,
    firstname => $fname,
    lastname => $lname,
    email => $email,
    phone => $phone,
    });
    $c->log->debug('After update');

    In the debug output from Catalyst I can see where the "Before update"
    gets printed but fails with no error that I can see during the update.
    Any help or advice in this matter would be greatly appreciated.
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.11 (GNU/Linux)
    Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

    iEYEARECAAYFAk2XbNAACgkQsK1mqepTLy9JNACeIsj8CR0d6utPMLRpgZQEs2+X
    N8UAnicZ07JpEK6kCxtwHdYGd+hW6VQt
    =NuEZ
    -----END PGP SIGNATURE-----

    _______________________________________________
    List: Catalyst@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/


    --
    रोहन मल�लेल�रवार
    -------------- next part --------------
    An HTML attachment was scrubbed...
    URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110403/73896b5a/attachment.htm
  • Adam Jimerson at Apr 3, 2011 at 7:25 pm
    I managed to find my error that was causing my problem:

    DBIx::Class::DynamicDefault::update(): Operation requires a primary key
    to be declared on 'TickIt::Schema::Result::Tech' via set_primary_key at
    /home/vendion/Projects/TickIt/script/../lib/TickIt/Controller/Admin.pm
    line 114

    Does it make a difference that none of the fields that I am updating is
    my primary_key on my database? Or is it complaining about the lack of a
    primary key all together?

    Rohan M wrote:
    Hi Adam,

    Did you try putting result-set in the variable rather than directly
    putting it into stash?

    my $user = $c->model('DB::Tech')->find({id => $userid});
    $user->update({ id => $username,
    firstname => $fname,
    lastname => $lname,
    email => $email,
    phone => $phone,});

    Try this and let us know

    On Sun, Apr 3, 2011 at 12:07 AM, Adam Jimerson wrote:

    First of all hello people of the list!

    I am working on my first Catalyst app and need some help updating an
    entry from my database.

    $c->stash( users_rs => $c->model('DB::Tech'));
    my $user = $c->stash->{users_rs}->find({ id => $userid });
    die "No such user: $userid\n" if (!$user);
    $c->stash(user => $user);
    $c->log->debug('Before update');
    $user->update({
    id => $username,
    firstname => $fname,
    lastname => $lname,
    email => $email,
    phone => $phone,
    });
    $c->log->debug('After update');

    In the debug output from Catalyst I can see where the "Before update"
    gets printed but fails with no error that I can see during the update.
    Any help or advice in this matter would be greatly appreciated.
    _______________________________________________
    List: Catalyst@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/



    --
    रोहन मल�लेल�रवार


    _______________________________________________
    List: Catalyst@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/

    -------------- next part --------------
    A non-text attachment was scrubbed...
    Name: signature.asc
    Type: application/pgp-signature
    Size: 267 bytes
    Desc: OpenPGP digital signature
    Url : http://lists.scsys.co.uk/pipermail/catalyst/attachments/20110403/767d6818/signature.pgp
  • Francisco Obispo at Apr 3, 2011 at 7:59 pm
    Remember that Catalyst uses DBIx::Class as an ORM, so it must be able to uniquely identified each row with a Primary Key.

    If you're going to update the primary key (which is not usually a good idea), make sure that you have 'ON UPDATE CASCADE' on referencing child tables, otherwise the operation will fail.

    Francisco
    On Apr 3, 2011, at 12:25 PM, Adam Jimerson wrote:

    I managed to find my error that was causing my problem:

    DBIx::Class::DynamicDefault::update(): Operation requires a primary key
    to be declared on 'TickIt::Schema::Result::Tech' via set_primary_key at
    /home/vendion/Projects/TickIt/script/../lib/TickIt/Controller/Admin.pm
    line 114

    Does it make a difference that none of the fields that I am updating is
    my primary_key on my database? Or is it complaining about the lack of a
    primary key all together?

    Rohan M wrote:
    Hi Adam,

    Did you try putting result-set in the variable rather than directly
    putting it into stash?

    my $user = $c->model('DB::Tech')->find({id => $userid});
    $user->update({ id => $username,
    firstname => $fname,
    lastname => $lname,
    email => $email,
    phone => $phone,});

    Try this and let us know

    On Sun, Apr 3, 2011 at 12:07 AM, Adam Jimerson <vendion@gmail.com
    wrote:

    First of all hello people of the list!

    I am working on my first Catalyst app and need some help updating an
    entry from my database.

    $c->stash( users_rs => $c->model('DB::Tech'));
    my $user = $c->stash->{users_rs}->find({ id => $userid });
    die "No such user: $userid\n" if (!$user);
    $c->stash(user => $user);
    $c->log->debug('Before update');
    $user->update({
    id => $username,
    firstname => $fname,
    lastname => $lname,
    email => $email,
    phone => $phone,
    });
    $c->log->debug('After update');

    In the debug output from Catalyst I can see where the "Before update"
    gets printed but fails with no error that I can see during the update.
    Any help or advice in this matter would be greatly appreciated.
    _______________________________________________
    List: Catalyst@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/



    --
    ???? ???????????


    _______________________________________________
    List: Catalyst@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/

    _______________________________________________
    List: Catalyst@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/
    Francisco Obispo
    Hosted@ Programme Manager
    email: fobispo@isc.org
    Phone: +1 650 423 1374 || INOC-DBA *3557* NOC
    Key fingerprint = 532F 84EB 06B4 3806 D5FA 09C6 463E 614E B38D B1BE
  • Eden Cardim at Apr 11, 2011 at 6:44 pm
    "Francisco" == Francisco Obispo writes:
    Francisco> Remember that Catalyst uses DBIx::Class as an ORM.

    No it doesn't, but you can use DBIx::Class if you want to, or any other
    ORM, for that matter, given it's perl and you can use whatever modules
    you want.

    Francisco> so it must be able to uniquely identified each row with
    Francisco> a Primary Key.

    This is orthogonal to the fact that you're using DBIC inside Catalyst,
    it actually depends on the data model you've implemented.

    --
    Eden Cardim Need help with your Catalyst or DBIx::Class project?
    Code Monkey http://www.shadowcat.co.uk/catalyst/
    Shadowcat Systems Ltd. Want a managed development or deployment platform?
    http://blog.edencardim.com/ http://www.shadowcat.co.uk/servers/
  • Tomas Doran at Apr 4, 2011 at 3:13 pm

    On 3 Apr 2011, at 20:25, Adam Jimerson wrote:

    Or is it complaining about the lack of a
    primary key all together?
    Yes.

    Also, you're probably better asking DBIx::Class questions on the
    DBIx::Class list :)

    Cheers
    t0m
  • Adam Jimerson at Apr 4, 2011 at 8:13 pm
    Thank you that solved my problem, also I will keep that in mind if I
    have any othr DBIx::Class questions/issues.

    Tomas Doran wrote:
    On 3 Apr 2011, at 20:25, Adam Jimerson wrote:

    Or is it complaining about the lack of a
    primary key all together?
    Yes.

    Also, you're probably better asking DBIx::Class questions on the
    DBIx::Class list :)

    Cheers
    t0m


    _______________________________________________
    List: Catalyst@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/

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupcatalyst @
categoriescatalyst, perl
postedApr 2, '11 at 6:37p
activeApr 11, '11 at 6:44p
posts7
users5
websitecatalystframework.org
irc#catalyst

People

Translate

site design / logo © 2022 Grokbase