$rs->search( { field => undef } )

creates sql like so:

...where field is null...



on the other hand

$rs->search( { field => { '!=' => undef } } )

produces:

...where field is not null...




On Wed, May 22, 2013 at 4:03 PM, Ekki Plicht (DF4OR) <e...@plicht.de> wrote:

> Hi.
> I am a little bit uncertain how DBIx::Class handles Null values in various
> circumstances.
>
> With the following table:
> "id",  { data_type => "integer", is_auto_increment => 1, is_nullable => 0
> },
> "id_prod", { data_type => "integer", is_foreign_key => 1, is_nullable => 1
> },
> "lang", { data_type => "varchar", is_nullable => 1, size => 2 },
> "size", { data_type => "varchar", is_nullable => 1, size => 2 },
> "atext", { data_type => "text", is_nullable => 1 },
> __PACKAGE__->set_primary_key("id");
> __PACKAGE__->add_unique_constraint("text_UNIQUE", ["size", "id_prod",
> "lang"]);
>
> What is the difference between
> ->search( { size => 'S',  lang => 'de', }, { key => 'text_UNIQUE' });
> and
> ->search( { size => 'S',  lang => 'de', id_prod => undef }, { key =>
> 'text_UNIQUE' });
>
> In the first case one constraint component (id_prod) is missing entirely,
> in the second case it's present but set to undef.
>
> Which of these two cases would be preferrable if the value of 'id_prod' is
> "Dont care"?
>
> What I did so far to find it out myself:
> Search CPAN docs high and low; google for appropriate search terms, check
> stackoverflow, all to no avail.
>
> What I could have done to help myself:
> Set up a database to simulate this. But I am at an early stage of
> development of a new DB and don't have no data yet. Sorry.
>
> TIA,
> Ekki
>
>
> _______________________________________________
> List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
> IRC: irc.perl.org#dbix-class
> SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
> Searchable Archive:
> http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk
>



-- 
 Will Trillich :: 812.454.6431

“Grading takes away all the fun from failing. And a huge part of education
is about failure.”  -- Shimon Schocken
_______________________________________________
List: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/dbix-class
IRC: irc.perl.org#dbix-class
SVN: http://dev.catalyst.perl.org/repos/bast/DBIx-Class/
Searchable Archive: http://www.grokbase.com/group/dbix-class@lists.scsys.co.uk

Reply via email to