# = FALSE vs. IS NOT TRUE

**URL:** <https://www.ruby-forum.com/t/false-vs-is-not-true/92285>\
**Category:** Rails\
**Created:** [April 17, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285 "2007-04-17T20:22:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 17, 2007, 8:22pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/1 "2007-04-17T20:22:09Z")

</div>

Hello,  
i have a column in my table ‘is\_inappropriate’ which is boolean,  
but can be null  
Here is my simplified code, and i want to keep conditions in hash  
type.  
@reviews ||=  
Review.find(  
:all,  
:conditions =\> {:is\_inappropriate =\> false})

sql result is :  
select \* from reviews where reviews.is\_inappropriate = False

but this is what i want :  
select \* from reviews where reviews.is\_inappropriate IS NOT TRUE

someone can helps me?

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 17, 2007, 10:05pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/2 "2007-04-17T22:05:37Z")

</div>

Jean-sÃ©bastien Jney wrote:

> Hello,  
> i have a column in my table ‘is\_inappropriate’ which is boolean,  
> but can be null  
> Here is my simplified code, and i want to keep conditions in hash  
> type.  
> @reviews ||=  
> Review.find(  
> :all,  
> :conditions =\> {:is\_inappropriate =\> false})
> 
> sql result is :  
> select \* from reviews where reviews.is\_inappropriate = False
> 
> but this is what i want :  
> select \* from reviews where reviews.is\_inappropriate IS NOT TRUE
> 
> someone can helps me?

eh, maybe this?  
@reviews ||=  
Review.find(  
:all,  
:conditions =\> {:is\_inappropriate =\> ‘IS NOT TRUE’})

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 17, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/3 "2007-04-17T23:21:38Z")

</div>

Just use:

:conditions =\> “is\_inappropriate IS NOT TRUE”

Chris

On Apr 17, 7:20 pm, Jean-Sébastien [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 17, 2007, 11:53pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/4 "2007-04-17T23:53:40Z")

</div>

:conditions =\> {:is\_inappropriate =\> ‘IS NOT TRUE’}) doesn’t work and  
i’m aware that :conditions can be a string but i want to have an hash

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 18, 2007, 12:08am UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/5 "2007-04-18T00:08:40Z")

</div>

Well, I’m afraid you can’t have a hash. The hash style lets you test  
equality, or a range. Those are the only options. If you want to  
generate the SQL “IS NOT TRUE”, then you have to use another style.

Chris

On Apr 17, 10:50 pm, Jean-Sébastien [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 18, 2007, 12:36am UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/6 "2007-04-18T00:36:42Z")

</div>

thanks chris, do you know if it is possible to mix hash and string  
value in :conditions ?

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 20, 2007, 4:33pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/7 "2007-04-20T16:33:21Z")

</div>

Yeah, you can do something like this:

query = “Jean”

self.find(:all, :conditions =\>  
[“name = :name AND is\_inappropriate IS NOT TRUE”,  
{:name =\> query}])

In other words, if you pass an array consisting of a string and a  
hash, the find method will substitute values in the string (like  
“:name” in this example) using the values that you’ve passed in the  
hash.

Chris

On Apr 17, 11:35 pm, Jean-Sébastien [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![jney](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/49beb7/32.png) [@jney](https://www.ruby-forum.com/u/jney)\
**Post date:** [April 20, 2007, 4:53pm UTC](https://www.ruby-forum.com/t/false-vs-is-not-true/92285/8 "2007-04-20T16:53:24Z")

</div>

Just in case you weren’t aware… the second you do ‘is\_inappropriate IS  
NOT  
TRUE’ you lock yourself into a specific database. Some databases treat  
TRUE  
as true, some use T., some use 1. Yuk. Of course, that’s not usually a  
problem but I thought I’d point it out.
