Hi, This is just kindof a RoR question, but since you all potentially do the same things as I do, I thought I''ll ask here.. Im trying to use the boolean type in the database. Migrations is no problem, it even converts the 0/1 values from my import CSV to false and true. However, I cannot make the :conditions part of a find work: Loading development environment (Rails 2.0.2)>> c = Club.find(1)=> #<Club id: 1, club_name: "Ume\214 Kuniba kai", logo: nil, currently_active: 1, created_at: "2008-03-07 12:52:35", updated_at: "2008-03-07 12:52:35">>> m = c.members.find(:first, :conditions => "is_active = 1")=> nil>> m = c.members.find(:first, :conditions => "is_active = true")ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: true: SELECT * FROM members WHERE (members.club_id = 1 AND (is_active = true)) LIMIT 1 from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:345:in `catch_schema_changes'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:256:in `select'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:55:in `select_all'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:532:in `find_by_sql'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1233:in `find_every'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1227:in `find_initial'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:502:in `find'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_many_association.rb:66:in `find'' from (irb):3>> m = c.members.find(:first, :conditions => "is_active = false")ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: false: SELECT * FROM members WHERE (members.club_id = 1 AND (is_active = false)) LIMIT 1 from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract_adapter.rb:150:in `log'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:345:in `catch_schema_changes'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:132:in `execute'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/sqlite_adapter.rb:256:in `select'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/database_statements.rb:7:in `select_all_without_query_cache'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/connection_adapters/abstract/query_cache.rb:55:in `select_all'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:532:in `find_by_sql'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1233:in `find_every'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1227:in `find_initial'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:502:in `find'' from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/active_record/associations/has_many_association.rb:66:in `find'' from (irb):4>> m = c.members.find(:first, :conditions => "is_active = 0")=> nil If I change the column to an integer, everything works, except of course the .toggle-method which does not know how to handle an integer value. What do I do? As you can see, I am using sqlite3 /Fredrik -- "Give up learning, and put an end to your troubles." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mar 7, 2008, at 7:00 AM, Fredrik Karlsson wrote:> Hi, > > This is just kindof a RoR question, but since you all potentially do > the same things as I do, I thought I''ll ask here.. > > Im trying to use the boolean type in the database. Migrations is no > problem, it even converts the 0/1 values from my import CSV to false > and true. > However, I cannot make the :conditions part of a find work: > > Loading development environment (Rails 2.0.2) >>> c = Club.find(1) > => #<Club id: 1, club_name: "Ume\214 Kuniba kai", logo: nil, > currently_active: 1, created_at: "2008-03-07 12:52:35", updated_at: > "2008-03-07 12:52:35"> >>> m = c.members.find(:first, :conditions => "is_active = 1") > => nil >>> m = c.members.find(:first, :conditions => "is_active = true") > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > true: SELECT * FROM members WHERE (members.club_id = 1 AND > (is_active = true)) LIMIT 1Have you tried: :conditions => [''is_active = ?'', true] and let the adapter deal with how to represent booleans for the column? -Rob Rob Biedenharn http://agileconsultingllc.com Rob-xa9cJyRlE0mWcWVYNo9pwxS2lgjeYSpx@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On 7 Mar 2008, at 12:00, Fredrik Karlsson wrote:> > Hi, > > This is just kindof a RoR question, but since you all potentially do > the same things as I do, I thought I''ll ask here.. > > Im trying to use the boolean type in the database. Migrations is no > problem, it even converts the 0/1 values from my import CSV to false > and true. > However, I cannot make the :conditions part of a find work: > > Loading development environment (Rails 2.0.2) >>> c = Club.find(1) > => #<Club id: 1, club_name: "Ume\214 Kuniba kai", logo: nil, > currently_active: 1, created_at: "2008-03-07 12:52:35", updated_at: > "2008-03-07 12:52:35"> >>> m = c.members.find(:first, :conditions => "is_active = 1") > => nil >>> m = c.members.find(:first, :conditions => "is_active = true")How about c.members.find(:first, :conditions => ["is_active = ?", true]) Fred.>>> > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > true: SELECT * FROM members WHERE (members.club_id = 1 AND > (is_active = true)) LIMIT 1 > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract_adapter.rb:150:in > `log'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:132:in > `execute'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:345:in > `catch_schema_changes'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:132:in > `execute'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:256:in > `select'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract/database_statements.rb:7:in > `select_all_without_query_cache'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract/query_cache.rb:55:in > `select_all'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:532:in > `find_by_sql'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:1233:in > `find_every'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:1227:in > `find_initial'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:502:in > `find'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/associations/has_many_association.rb:66:in > `find'' > from (irb):3 >>> m = c.members.find(:first, :conditions => "is_active = false") > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > false: SELECT * FROM members WHERE (members.club_id = 1 AND > (is_active = false)) LIMIT 1 > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract_adapter.rb:150:in > `log'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:132:in > `execute'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:345:in > `catch_schema_changes'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:132:in > `execute'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/sqlite_adapter.rb:256:in > `select'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract/database_statements.rb:7:in > `select_all_without_query_cache'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/connection_adapters/abstract/query_cache.rb:55:in > `select_all'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:532:in > `find_by_sql'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:1233:in > `find_every'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:1227:in > `find_initial'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/base.rb:502:in > `find'' > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > active_record/associations/has_many_association.rb:66:in > `find'' > from (irb):4 >>> m = c.members.find(:first, :conditions => "is_active = 0") > => nil > > If I change the column to an integer, everything works, except of > course the .toggle-method which does not know how to handle an integer > value. > > What do I do? As you can see, I am using sqlite3 > > /Fredrik > -- > "Give up learning, and put an end to your troubles." > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, You guys are sooo good. Of course that worked. Thanks! /Fredrik On Fri, Mar 7, 2008 at 2:00 PM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 7 Mar 2008, at 12:00, Fredrik Karlsson wrote: > > > > > Hi, > > > > This is just kindof a RoR question, but since you all potentially do > > the same things as I do, I thought I''ll ask here.. > > > > Im trying to use the boolean type in the database. Migrations is no > > problem, it even converts the 0/1 values from my import CSV to false > > and true. > > However, I cannot make the :conditions part of a find work: > > > > Loading development environment (Rails 2.0.2) > >>> c = Club.find(1) > > => #<Club id: 1, club_name: "Ume\214 Kuniba kai", logo: nil, > > currently_active: 1, created_at: "2008-03-07 12:52:35", updated_at: > > "2008-03-07 12:52:35"> > >>> m = c.members.find(:first, :conditions => "is_active = 1") > > => nil > >>> m = c.members.find(:first, :conditions => "is_active = true") > > How about c.members.find(:first, :conditions => ["is_active = ?", true]) > > Fred. > > > > >>> > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > > true: SELECT * FROM members WHERE (members.club_id = 1 AND > > (is_active = true)) LIMIT 1 > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract_adapter.rb:150:in > > `log'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:132:in > > `execute'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:345:in > > `catch_schema_changes'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:132:in > > `execute'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:256:in > > `select'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract/database_statements.rb:7:in > > `select_all_without_query_cache'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract/query_cache.rb:55:in > > `select_all'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:532:in > > `find_by_sql'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:1233:in > > `find_every'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:1227:in > > `find_initial'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:502:in > > `find'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/associations/has_many_association.rb:66:in > > `find'' > > from (irb):3 > >>> m = c.members.find(:first, :conditions => "is_active = false") > > ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: > > false: SELECT * FROM members WHERE (members.club_id = 1 AND > > (is_active = false)) LIMIT 1 > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract_adapter.rb:150:in > > `log'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:132:in > > `execute'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:345:in > > `catch_schema_changes'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:132:in > > `execute'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/sqlite_adapter.rb:256:in > > `select'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract/database_statements.rb:7:in > > `select_all_without_query_cache'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/connection_adapters/abstract/query_cache.rb:55:in > > `select_all'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:532:in > > `find_by_sql'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:1233:in > > `find_every'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:1227:in > > `find_initial'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/base.rb:502:in > > `find'' > > from /Library/Ruby/Gems/1.8/gems/activerecord-2.0.2/lib/ > > active_record/associations/has_many_association.rb:66:in > > `find'' > > from (irb):4 > >>> m = c.members.find(:first, :conditions => "is_active = 0") > > => nil > > > > If I change the column to an integer, everything works, except of > > course the .toggle-method which does not know how to handle an integer > > value. > > > > What do I do? As you can see, I am using sqlite3 > > > > /Fredrik > > -- > > "Give up learning, and put an end to your troubles." > > > > > > > > > > > >-- "Give up learning, and put an end to your troubles." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---