Skip Menu |

This queue is for tickets about the DBIx-Class CPAN distribution.

Report information
The Basics
Id: 108898
Status: resolved
Priority: 0/
Queue: DBIx-Class

People
Owner: Nobody in particular
Requestors: martin.renvoize [...] ptfs-europe.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: find_or_create accorss relationships bug?
Date: Fri, 13 Nov 2015 12:24:53 +0000
To: bug-DBIx-Class [...] rt.cpan.org
From: "Renvoize, Martin" <martin.renvoize [...] ptfs-europe.com>
So, I pasted the above into IRC this morning and castaway at least agreed he 'thinks' it's likely a bug.. so I thought I'd record it. I am intending to submit a pull request with at least a failing test case shortly. 1 So I'm attempting to populate a bridge table. 2 3 The three tables in question are: 4 5 Role, Privilege and RolePrivilege. 6 7 My code is: 8 9 $schema->resultset('RolePrivilege')->find_or_create({role => {name => 'admin'}, privilege => {name => 'config-update'}); 10 11 Looking at DBIC_TRACE this gets most of the way there.. 12 13 SELECT "me"."id", "me"."name" 14 FROM "roles" "me" 15 WHERE "me"."name" = 'admin'; 16 17 SELECT "me"."id", "me"."name", "me"."description" 18 FROM "privileges" "me" 19 WHERE "me"."name" = 'config_update'; 20 21 But the final insert doesn't do a 'find' before attempting the create, so I get constraint failures. 22 23 INSERT INTO "role_privileges"( "privilege", "role" ) 24 VALUES( '1', '20' ) 25 26 Am I expecting too much of the logic.. bug of feature? Martin Renvoize Software Engineer, PTFS Europe Ltd Content Management and Library Solutions Skype: Landline: 0203 286 8685 Mobile: 07725985636 http://www.ptfs-europe.com
On Fri Nov 13 13:25:34 2015, martin.renvoize@ptfs-europe.com wrote: Show quoted text
> 7 My code is: > 8 > 9 $schema->resultset('RolePrivilege')->find_or_create({role => > {name => 'admin'}, privilege => {name => 'config-update'}); > 10
There is something specific about your code that makes things fail - please get me the definitions of RolePrivelege and the related classes. The functionality you described works just fine: ~/devel/dbic$ perl -It/lib -Ilib -MDBICTest -e ' my $s = DBICTest->init_schema; $s->storage->debug(1); $s->resultset("CD_to_Producer")->find_or_create({ cd => { cdid => 2 }, producer => { producerid => 1 } }) ' producing SELECT me.cd, me.producer, me.attribute FROM cd_to_producer me WHERE ( ( me.cd = ? AND me.producer = ? ) ): '2', '1' SELECT me.cdid, me.artist, me.title, me.year, me.genreid, me.single_track FROM cd me WHERE ( me.cdid = ? ): '2' SELECT me.producerid, me.name FROM producer me WHERE ( me.producerid = ? ): '1' INSERT INTO cd_to_producer ( cd, producer) VALUES ( ?, ? ): '2', '1'
On Wed Mar 30 20:51:51 2016, RIBASUSHI wrote: Show quoted text
> On Fri Nov 13 13:25:34 2015, martin.renvoize@ptfs-europe.com wrote:
> > 7 My code is: > > 8 > > 9 $schema->resultset('RolePrivilege')->find_or_create({role => > > {name => 'admin'}, privilege => {name => 'config-update'}); > > 10
> > > There is something specific about your code that makes things fail - > please get me the definitions of RolePrivelege and the related > classes. > > The functionality you described works just fine:
Hi Martin! You never got back to me way-back-when. Did something come out of this bug, or should I close it as ¯\_(ツ)_/¯
Subject: Re: [rt.cpan.org #108898] find_or_create accorss relationships bug?
Date: Mon, 29 Jan 2018 13:19:37 +0000
To: bug-DBIx-Class [...] rt.cpan.org
From: "Renvoize, Martin" <martin.renvoize [...] ptfs-europe.com>
I think just close it.. I'm afraid that's long enough ago that's I've completely forgotten what the issue was and I wasn't sensible enough to note it down at the time :(, it's not causing me problems in my current codebase so I presume it was my mistake somewhere. *Martin Renvoize* Development Manager *T:* +44 (0) 1483 378728 *F:* +44 (0) 800 756 6384 *E:* martin.renvoize@ptfs-europe.com www.ptfs-europe.com <https://www.ptfs-europe.com> Registered in the United Kingdom No. 06416372 VAT Reg No. 925 7211 30 The information contained in this email message may be privileged, confidential and protected from disclosure. If you are not the intended recipient, any dissemination, distribution or copying is strictly prohibited. If you think that you have received this email message in error, please email the sender at info@ptfs-europe.com On 28 January 2018 at 17:33, Peter Rabbitson via RT < bug-DBIx-Class@rt.cpan.org> wrote: Show quoted text
> <URL: https://rt.cpan.org/Ticket/Display.html?id=108898 > > > On Wed Mar 30 20:51:51 2016, RIBASUSHI wrote:
> > On Fri Nov 13 13:25:34 2015, martin.renvoize@ptfs-europe.com wrote:
> > > 7 My code is: > > > 8 > > > 9 $schema->resultset('RolePrivilege')->find_or_create({role => > > > {name => 'admin'}, privilege => {name => 'config-update'}); > > > 10
> > > > > > There is something specific about your code that makes things fail - > > please get me the definitions of RolePrivelege and the related > > classes. > > > > The functionality you described works just fine:
> > > Hi Martin! > > You never got back to me way-back-when. Did something come out of this > bug, or should I close it as ¯\_(ツ)_/¯ > >
On Mon Jan 29 14:20:58 2018, martin.renvoize@ptfs-europe.com wrote: Show quoted text
> I think just close it.. I'm afraid that's long enough ago that's I've > completely forgotten what the issue was and I wasn't sensible enough to > note it down at the time :(
¯\_(ツ)_/¯ it is then ;)