Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: DBIx::Class Build a Where Clause with multiple ORs and ANDs

by phildeman (Beadle)
on Jan 03, 2018 at 15:34 UTC ( #1206604=note: print w/replies, xml ) Need Help??


in reply to Re: DBIx::Class Build a Where Clause with multiple ORs and ANDs
in thread DBIx::Class Build a Where Clause with multiple ORs and ANDs

Hi poj,

Thanks for your response. The send_email => {'!=' , ....} was deliberate.
I do not want send_email to be undefined or have a value of '0000-00-00', when
status is equal to Offered, Denied, Cancelled, or Conditional Offer.

However, if the status equals Review, the sent_email can have any value.

-Phil-

  • Comment on Re^2: DBIx::Class Build a Where Clause with multiple ORs and ANDs

Replies are listed 'Best First'.
Re^3: DBIx::Class Build a Where Clause with multiple ORs and ANDs
by poj (Monsignor) on Jan 03, 2018 at 16:10 UTC

    This logic is always TRUE

    -or => [ sent_email => {'!=', undef }, sent_email => {'!=', '0000-00-00'} ],

    for it to be FALSE the sent_email must be both undefined AND '0000-00-00' which is not possible. I think you want

    -or =>[ status => 'Review' , -and => [ -or => [ status => 'Offered', status => 'Denied', status => 'Cancelled', status => 'Conditional Offer', ], sent_email => {'!=', undef }, sent_email => {'!=', '0000-00-00'}, ], ],
    poj
Re^3: DBIx::Class Build a Where Clause with multiple ORs and ANDs
by 1nickt (Monsignor) on Jan 03, 2018 at 15:55 UTC

    I do not want send_email to be undefined or have a value of '0000-00-00', when status is equal to Offered, Denied, Cancelled, or Conditional Offer.

    However, if the status equals Review, the sent_email can have any value.

    But in your initial example in your OP you said:

    The where clause should be:
    WHERE status='Review' OR ( ( status='Offered' OR status='Denied' OR status='Cancelled' OR status='Conditional Offer') AND ( sent_email is NULL OR sent_email='0000-00-00') )

    I showed you how to achieve the outcome described in your most recent comment in an earlier thread. I've updated my response to your initial query today now that you've clarified your spec.


    The way forward always starts with a minimal test.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1206604]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2018-06-24 08:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (126 votes). Check out past polls.

    Notices?