Hi All, I am a real neophyte with Rails and am struggling with something. I hope you can point me in the right direction. I have a model of an object that class Thing< ActiveRecord::Base attr_accessor :locator_id has_one :otherthing has_one :differentthing end I can create and delete these things until the cows come home. However, trying to change the data and save/update I get a rendered SQL error in the form: ActionView::TemplateError (Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''WHERE `id` = 40'' at line 1: UPDATE things SET WHERE `id` = 40)...etc. So, I reduce this to it''s elements...a find followed immediately followed by a save and I get this error. So, it looks to me like a mismatch in the SQL that is generated and the version of MySql is Server version: 5.0.41 MySQL Community Server (GPL) and Rails 1.2.3. Any help very much appreciated. Sincerely, Tim -- 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-/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 1 Nov 2007, at 16:02, Tim Walker wrote:> > Hi All, > > I am a real neophyte with Rails and am struggling with something. I > hope > you can point me in the right direction. > > I have a model of an object that > > class Thing< ActiveRecord::Base > attr_accessor :locator_id > has_one :otherthing > has_one :differentthing > end > > I can create and delete these things until the cows come home. > However, > trying to change the data and save/update I get a rendered SQL error > in > the form: > > ActionView::TemplateError (Mysql::Error: You have an error in your SQL > syntax; check the manual that corresponds to your MySQL server version > for the right syntax to use near ''WHERE `id` = 40'' at line 1: UPDATE > things SET WHERE `id` = 40)...etc. > > So, I reduce this to it''s elements...a find followed immediately > followed by a save and I get this error.That sql just looks wrong. What columns exist on the table. Are you passing any extra options into find ? Fred
Frederick Cheung wrote:> On 1 Nov 2007, at 16:02, Tim Walker wrote: > >> attr_accessor :locator_id >> ActionView::TemplateError (Mysql::Error: You have an error in your SQL >> syntax; check the manual that corresponds to your MySQL server version >> for the right syntax to use near ''WHERE `id` = 40'' at line 1: UPDATE >> things SET WHERE `id` = 40)...etc. >> >> So, I reduce this to it''s elements...a find followed immediately >> followed by a save and I get this error. > > That sql just looks wrong. What columns exist on the table. Are you > passing any extra options into find ? > > FredHi Fred, Thank you for taking a look. I agree the SQL just looks wroung. The SET in particular is wierd. Below my sig I have: 1) Reproducing it with the console 2) The card object 3) The cardfront object 4) The cardback object 5) The (3) tables involved. Imagine modeling a playing card. A card "has a" cardfront and a cardback. Any help very much appreciated. Tim 1) Reproducing it with the console Loading development environment.>> @card = Card.find(:first, :conditions => 40)=> #<Card:0x3563904 @attributes={"id"=>"40"}>>> @card.saveActiveRecord::StatementInvalid: Mysql::Error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ''WHERE `id` = 40'' at line 1: UPDATE cards SET WHERE `id` = 40 2) The card object class Card < ActiveRecord::Base has_one :cardfront has_one :cardback end 3) The cardfront object class Cardfront < ActiveRecord::Base belongs_to :card end 4) The cardback object class Cardback < ActiveRecord::Base belongs_to :card end The tables look like: CREATE TABLE `cards` ( `id` int(11) NOT NULL auto_increment, PRIMARY KEY (`id`) ) CREATE TABLE `cardfronts` ( `id` int(11) NOT NULL auto_increment, `theme` text, `priority` int(11) default NULL, `estimate` int(11) default NULL, `notes` text, `card_id` int(11) default NULL, PRIMARY KEY (`id`) ) CREATE TABLE `cardbacks` ( `id` int(11) NOT NULL auto_increment, `card_id` int(11) default NULL, PRIMARY KEY (`id`) ) -- 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-/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 1 Nov 2007, at 17:24, Tim Walker wrote:> > Frederick Cheung wrote: >> On 1 Nov 2007, at 16:02, Tim Walker wrote: >> >>> attr_accessor :locator_id >>> ActionView::TemplateError (Mysql::Error: You have an error in your >>> SQL >>> syntax; check the manual that corresponds to your MySQL server >>> version >>> for the right syntax to use near ''WHERE `id` = 40'' at line 1: UPDATE >>> things SET WHERE `id` = 40)...etc. >>> >>> So, I reduce this to it''s elements...a find followed immediately >>> followed by a save and I get this error. >> >> That sql just looks wrong. What columns exist on the table. Are you >> passing any extra options into find ? >> >> Fred > > Hi Fred, > > Thank you for taking a look. I agree the SQL just looks wroung. The > SET > in particular is wierd. >I''ve looked at the source and this is just a bug in rails. It''s just not expecting a table with no attributes other than the primary key. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On 1 Nov 2007, at 17:24, Tim Walker wrote: > >>>> things SET WHERE `id` = 40)...etc. >> >> Thank you for taking a look. I agree the SQL just looks wroung. The >> SET >> in particular is wierd. >> > > I''ve looked at the source and this is just a bug in rails. It''s just > not expecting a table with no attributes other than the primary key. > > FredI am indebted. I was wondering about that, but the add''s and delete''s worked fine and being new to Rails (and to ORM in general) thought I was being really stupid. Makes sense now that you''ve sussed it out, the SET would have a collection of attributes, which just ainna there, I''m assuming. Thank you Frederik, hope I can return the favor someday. Sincerely, Tim -- 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-/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 -~----------~----~----~----~------~----~------~--~---