On 28 Apr 2011, at 13:13, Owain <[email protected]> wrote:
> On Apr 28, 12:57 pm, Frederick Cheung <[email protected]> > wrote: > >>> mysql> insert into confirmations (quote_id) values(188); >>> Query OK, 1 row affected (0.01 sec) >> >>> mysql> select * from confirmations where quote_id = 188; >> >> Why are you filtering by quote_id here? >> > > Fred, > > Just to show that the mysql CLI client allowed me to manually add > another row with the same quote_id of 188. So it is not mysql server > that is reporting the Duplicate Entry/Statement invalid. It is being > reported by the mysql adapter of ActiveRecord. > On closer inspection it may be that the duplicate entry error is coming from the primary key (your insert was explicitly setting the id to 185) Fred > Here is more of the backtrace which I omitted earlier. > > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/abstract_adapter.rb:227:in `log' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/mysql_adapter.rb:324:in `execute' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/abstract/database_statements.rb:259:in > `insert_sql' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/mysql_adapter.rb:334:in `insert_sql' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/abstract/database_statements.rb:44:in > `insert_without_query_dirty' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/abstract/query_cache.rb:19:in `insert' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > base.rb:2961:in `create_without_timestamps' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > timestamp.rb:53:in `create_without_callbacks' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > callbacks.rb:266:in `create' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > base.rb:2927:in `create_or_update_without_callbacks' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > callbacks.rb:250:in `create_or_update' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > base.rb:2577:in `save_without_validation' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > validations.rb:1090:in `save_without_dirty' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > dirty.rb:79:in `save_without_transactions' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:229:in `send' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:229:in `with_transaction_returning_status' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > connection_adapters/abstract/database_statements.rb:136:in > `transaction' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:182:in `transaction' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:228:in `with_transaction_returning_status' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:196:in `save' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:208:in `rollback_active_record_state!' > /usr/lib64/ruby/gems/1.8/gems/activerecord-2.3.10/lib/active_record/ > transactions.rb:196:in `save' > [RAILS_ROOT]/app/controllers/confirmation_controller.rb:17:in > `create' > > > The thing is that the SQL being reported looks completely correct and > should not fail. > > Any ideas? > > O. > > -- > 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 [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > -- 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 [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

