Hello! I have a rails app using a mysql. Now I need to configure it with sqlite. I change database settings in config/database.yml and Gemfile file and run rake db:create rake db:migrate and did not get any errors. But in view a have a code <%=@user.likes.size%> and get error SQLite3::SQLException: near "to": syntax error: SELECT COUNT(*) FROM "likes" WHERE ("likes".to = 1) in sqlite console sql query working with this syntax SELECT COUNT(*) FROM "likes" WHERE ("likes"."to" = 1) Why on mysql it''s working, but not working in sqlite?How i can fix it? rails -v Rails 3.0.7 ruby -v ruby 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0] sqlite3 -version 3.6.12 -- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Mon, Jul 18, 2011 at 3:04 PM, Aegorov Egorov <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> SQLite3::SQLException: near "to": syntax error: SELECT COUNT(*) FROM > "likes" WHERE ("likes".to = 1) > in sqlite console sql query working with this syntax > SELECT COUNT(*) FROM "likes" WHERE ("likes"."to" = 1)Apparently the SQLite3 adapter isn''t quoting that field name, and unfortunately for you, "TO" is a SQL reserved word. The best solution would be to change that. :-) HTH, -- Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org http://about.me/hassanschroeder twitter: @hassan -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
1 Thank you!it''s help me. I guess that this is the problem. Hassan Schroeder wrote in post #1011501:> On Mon, Jul 18, 2011 at 3:04 PM, Aegorov Egorov <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >> SQLite3::SQLException: near "to": syntax error: SELECT COUNT(*) FROM >> "likes" WHERE ("likes".to = 1) >> in sqlite console sql query working with this syntax >> SELECT COUNT(*) FROM "likes" WHERE ("likes"."to" = 1) > > Apparently the SQLite3 adapter isn''t quoting that field name, and > unfortunately for you, "TO" is a SQL reserved word. > > The best solution would be to change that. :-) > > HTH, > -- > Hassan Schroeder ------------------------ hassan.schroeder-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org > http://about.me/hassanschroeder > twitter: @hassan-- Posted via http://www.ruby-forum.com/. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.