mysql - Ruby TinyInt(1)? -
i have mysql table defined status flag (which tinyint(1)). when try check whether value true or false seem arrive @ erroneous result. is, doesn't see value legit true or value, rather test's if it's not "nil" or alike - hence "doesn't seem work"
results.each_hash |row| # tried # (a) if row['status'] # - doesn't seem work end # (b) if row['status'].to_i == 1 # seems correct end # (c) if row['status'] == false # doesn't seem work end end
what correct approach checking value (tinyint(1)) should trueclass or falseclass in ruby; (c) doesn't work itself.
this reference used - i'm assuming should apply in rails , in ruby (unless activerecord work) - http://www.orthogonalthought.com/blog/index.php/2007/06/mysql-and-ruby-on-rails-datatypes/
from active_record-3.2.13
, abstract_mysql_adapter.rb
code line 96:
# default, mysqladapter consider columns of type <tt>tinyint(1)</tt> # boolean. if wish disable emulation (which default # behavior in versions 0.13.1 , earlier) can add following line # application.rb file: # # activerecord::connectionadapters::mysql[2]adapter.emulate_booleans = false
Comments
Post a Comment