[Dbix-class] Unable to satisfy requested constraint

Christian Lackas lackas at lackas.net
Thu Jun 16 20:20:50 GMT 2011


Hi Everybody,

in one of my Catalyst-based applications I am experiencing a strange
behavior.

In a Schema class I have a function that uses find() on a resultset of
the same schema:

    $self->result_source->schema->resultset( $self->tablename )->find( $self->dataid );

(e.g. tablename is 'Images' and dataid the id of an entry in the Images
table). This used to work fine for quite some time, however, then one
day (on a new server, but with same software CentOS 5.6, DBIx::Class
0.08126, perl 5.10.1, more details on request) I got this error message:

    DBIx::Class::ResultSet::find(): Unable to satisfy requested constraint
    'ImagesAll', no values for column(s): 'sopinstanceuid', 'seriesid'

In Schema::Images I have defined:

    __PACKAGE__->set_primary_key("id");
    __PACKAGE__->add_unique_constraint( "ImagesAll", [ "sopinstanceuid", "seriesid" ] );

and I would have expected that DBIx::Class would automatically do the
right thing (as it typically does) and use the primary key id, however,
for some reason it seems to think that it has to use the 'ImagesAll'
unique constraint.

My workaround to this issue is to explicitly specify the 'key' to be
used:

    $self->result_source->schema->resultset( $table )->find( 
            { id => $self->dataid }, { key => 'primary' } )

Which does work fine, however, I would really like to know why this
broke, mainly since I don't want to have to replace all find() calls.

Unfortunately, in the tests I wrote I could not reproduce the issue and
the same function with same parameters works without any issue.

Does this ring a bell for anybody? And input is appreciated. Anything I
could do to debug the situation?

Thanks,
 Christian

-- 
inviCRO, LLC -- In Imaging Yours
http://www.invicro.com/  http://www.spect-ct.com/



More information about the DBIx-Class mailing list