develooper Front page | perl.perl5.porters | Postings from February 2018

Re: Moderation

Thread Previous | Thread Next
Matt S Trout
February 13, 2018 18:59
Re: Moderation
Message ID:
> Apologies for breaking my silence. There is an ever-present piece of the 
> narrative being nonchalantly pushed around that simply can not be 
> allowed to stand.

Given you described the following (far from entirely successful but honestly
genuine) attempt at helping somebody as an 'abuse episode' -

20:54 -!- krebbit [] has joined #dbix-class
20:54 < krebbit> is there a createOrUpdate in DBI i should look at?
20:56 -!- rhesa [] has joined #dbix-class
20:58 < krebbit> reading the documentation it seems there is only one way to create an object in teh databse
20:58 < krebbit> ->create(\{})
20:59 < krebbit> can i not work with my model objects when creating an entry and need to create a literal hash to be passed to the create method?
21:02 <@mst> krebbit: rubbish
21:02 <@mst> krebbit: have you read the DBIx::Class::ResultSet docs?
21:02 < krebbit>
21:03 < krebbit> im looking at this and it states I need to pass an explicit hash of properties when creating a new object
21:03 <@mst> which specifically tells you that it's a shortcut for ->new_result + ->insert
21:03 <@mst> please try reading the whole of the method's documentation :)
21:03 <@mst> also, notice that it mentions find_or_create
21:04 <@mst> and that there's a create_or_update method
21:04 <@mst> and that there's a find_or_new method
21:04 < krebbit> same thing
21:04 <@mst> not the same thing at all
21:04 < krebbit> it requires an explicit hash
21:04 <@mst> not the same thing at all
21:04 <@mst> new_result returns an uninserted row object
21:04 <@mst> which is specifically what you were asking for
21:04 <@mst> I don't understand what the problem is
21:04 < krebbit> totally let me rephrase
21:05 -!- melmothX [] has quit [Quit: #]
21:05 <@mst> my $uninserted = $rs->new_result({});
21:05 <@mst> $uninserted->some_col($value);
21:05 <@mst> $uninserted->insert;
21:05 <@mst> would totally work fine
21:05 < shadowpaste> "krebbit" at pasted "example OOO" (10 lines) at
21:06 <@mst> yeah, so that's completely wrong
21:06 < krebbit> I wonder if I can build up an entry with an OOO appraoch using the auto generated classes
21:06 <@mst> use new_result
21:06 <@mst> and insert
21:06 <@mst> rather than inventing stuff that doesn't exist
21:07 <@mst> I mean, admittedly, that code is pure antipattern anyway, it's javabean style which mostly only exists because position arguments to constructors are horrible
21:07 <@mst> but if you wrote it properly, it would work fine
21:08 <@mst> my $f24League = $schema->resultset('F24League')->new_result({});
21:08 <@mst> ...
21:08 <@mst> $f24League->insert;
21:08 <@mst> would work
21:08 < krebbit> oh perfect
21:08 < krebbit> let me try that
21:08 < krebbit> thank you for your help so far
21:08 <@mst> wtf is OOO though?
21:11 < avenj> Obtuse Object Orientation
21:12 < krebbit> ;) 
21:12 < krebbit> that did work, thanks mst.
21:12 < krebbit> the API is not intended that way though?
21:12 <@mst> that's absolutely supported
21:13 <@mst> being able to handle uninserted objects was a feature in 0.01
21:13 <@mst> because I was really annoyed Class::DBI didn't
21:13 < krebbit> gotcha, now if I build up that object from an XML feed
21:13 < krebbit> and I have an object with that unique key persisted already
21:13 <@mst> right at the start of this conversation
21:14 <@mst> I pointed out to you that immediately above create() in the resultset docs
21:14 <@mst> was find_or_new()
21:14 <@mst> because I thought that was what you were going to want
21:14 -!- Vandal [~Vandal@] has quit [Quit: Any sufficiently advanced technology is indistinguishable from magic. (Arthur C. Clarke)]
21:14 <@mst> maybe now you could look at the docs for it like I suggested twice?
21:14 < krebbit> mst no worries, wont bother you further
21:14 <@mst> because along with $new->insert_or_update it exists to handle exactly that case
21:14 < krebbit> thatnks for your help
21:14 -!- krebbit [] has left #dbix-class []
21:15 <@mst> ... what
21:15 < purl> Unimplemented. or see dotdotdot
21:15  * mst sighs

it rather seems to me that your opinion as to what level and form of vitriol
is and isn't acceptably classifiable as 'abuse' is, at best, situational.

Matt S Trout - Shadowcat Systems - Perl consulting with a commit bit and a clue

Email me now on mst (at) and let's chat about how our CPAN
commercial support, training and consultancy packages could help your team.

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About