[Dbix-class] "row not found" updating partitioned table in PgSQL
Alex Povolotsky
tarkhil at over.ru
Thu Nov 10 12:20:03 GMT 2016
Thank you for quick and complete answer. I'll do my best investiganting
postgres part of the case and eventually it will work fine)
On 10.11.2016 0:31, Matt S Trout wrote:
> On Wed, Nov 09, 2016 at 11:50:32PM +0300, Alex Povolotsky wrote:
>> Hello
>>
>> I do see everyone busy resolving fate of DBIx::Class, but I have a
>> problem right here and now.
>>
>> I have a table, in Postgres, partitioned with all required triggers.
>>
>> When I update a row, posrgres returns "UPDATE 0". I'm not sure if
>> it's a bug or a feature, but DBIx::Class becomes VERY upset on it,
>> writing tons of lines like
>>
>> Mojo::Reactor::EV: I/O watcher failed: DBIx::Class::Row::update():
>> Can't update Schema::Result::InstaImages1=HASH(0x197e690): row not
>> found at imageloader-ev-new line 107
>>
>> Can I somehow turn off this warning?
>
> It's actually an exception, not a warning - because it normally means
> something like "the row you're trying to UPDATE has been DELETEd under you"
> which is normally really not a good thing. So, *generally*, feature. But
> obviously not for you right now.
>
> However, the row count is the return value of $storage->update, so what
> you could do is something like
>
> package My::Storage {
> use mro 'c3';
> use base qw(DBIx::Class::Storage::DBI::Pg);
>
> sub update {
> my $self = shift;
> my ($source) = @_;
> my $ret = $self->next::method(@_);
> return 1 if $source->name eq 'partitioned_table';
> return $ret;
> }
> }
>
> and then in your Schema class
>
> __PACKAGE__->storage_type('My::Storage');
>
> and that way you're only disabling the sanity check for the specific table.
>
> Or you could always patch DBIx::Class to provide a flag to disable it, but
> when/whether you'd be able to get such a patch upstream is obviously not
> something that's entirely predictable at this point.
>
More information about the DBIx-Class
mailing list