# 1 or true in TINYINT(1) column?

**URL:** <https://www.ruby-forum.com/t/1-or-true-in-tinyint-1-column/147137>\
**Category:** Rails\
**Created:** [August 28, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/1-or-true-in-tinyint-1-column/147137 "2008-08-28T19:13:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.francisco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58f4c7/32.png) [@j.francisco](https://www.ruby-forum.com/u/j.francisco)\
**Post date:** [August 28, 2008, 7:13pm UTC](https://www.ruby-forum.com/t/1-or-true-in-tinyint-1-column/147137/1 "2008-08-28T19:13:34Z")

</div>

Hello, there is a table that has a column TINYINT(1) called status.  
Through mysql console I see its value as 1 (when is true) but if I do  
this in Rails console:

Mytable.status  
=\> true

give me “true” rather “1”.

How could I change 1 to true using some method?  
Or true to 1?

---

<div class="post-metadata">

**Author:** ![j.francisco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58f4c7/32.png) [@j.francisco](https://www.ruby-forum.com/u/j.francisco)\
**Post date:** [August 28, 2008, 8:42pm UTC](https://www.ruby-forum.com/t/1-or-true-in-tinyint-1-column/147137/2 "2008-08-28T20:42:10Z")

</div>

On Aug 28, 2008, at 1:08 PM, j.francisco wrote:

> Or true to 1?  
> Is this behavior causing a problem? If so, then explain your problem  
> and not simply the behavior that you see.

If you look at:  
[http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html](http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/MysqlAdapter.html)

You’ll find one possible answer:

By default, the MysqlAdapter will consider all columns of type tinyint(1) as boolean. If you wish to disable this emulation (which was the default behavior in versions 0.13.1 and earlier) you can add the following line to your environment.rb file: ActiveRecord::ConnectionAdapters::MysqlAdapter.emulate\_booleans = false You then loose all booleans because MySQL doesn't have a true Boolean column type.

[http://dev.mysql.com/doc/refman/5.1/en/other-vendor-data-types.html](http://dev.mysql.com/doc/refman/5.1/en/other-vendor-data-types.html)

-Rob

Rob B. [http://agileconsultingllc.com](http://agileconsultingllc.com)  
removed\_email\_address@domain.invalid

---

<div class="post-metadata">

**Author:** ![j.francisco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/58f4c7/32.png) [@j.francisco](https://www.ruby-forum.com/u/j.francisco)\
**Post date:** [August 28, 2008, 9:03pm UTC](https://www.ruby-forum.com/t/1-or-true-in-tinyint-1-column/147137/3 "2008-08-28T21:03:18Z")

</div>

Thanks Rob, that’s enough to solve my problem.

JF

On Aug 28, 1:41 pm, Rob B. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
