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

Re: Moderation

Thread Previous | Thread Next
From:
Matt S Trout
Date:
February 13, 2018 18:59
Subject:
Re: Moderation
Message ID:
20180213181625.GI21411@newagaton.scsys.co.uk
> 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 [683b9641@ircip1.mibbit.com] has joined #dbix-class
20:54 < krebbit> is there a createOrUpdate in DBI i should look at?
20:56 -!- rhesa [~rhesa@1F2E5002.dsl.pool.telekom.hu] 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> http://search.cpan.org/~ribasushi/DBIx-Class-0.082820/lib/DBIx/Class/ResultSet.pm#create
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 [~melmoth@25-213.dsl.iskon.hr] 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 217.168.150.38 pasted "example OOO" (10 lines) at http://paste.scsys.co.uk/493757
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@176.209.221.52] 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 [683b9641@ircip1.mibbit.com] 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

http://shadowcat.co.uk/blog/matt-s-trout/   http://twitter.com/shadowcat_mst/

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

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About