Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error with CompositePrimaryKeys #7

Open
jmartinmmi opened this issue Jan 22, 2010 · 2 comments
Open

Error with CompositePrimaryKeys #7

jmartinmmi opened this issue Jan 22, 2010 · 2 comments

Comments

@jmartinmmi
Copy link

Hello,

I am using the compositeprimarykeys gem and I am getting a error when I try to save a record with the LOW_PRIORTY keyword:

s = SurveyInfo.find_by_Client "Test Client"
=> #<SurveyInfo Client_Survey_Information_ID: 148, Client: "Test Client", Client_Division: "Test", Client_Survey: "Test 01", Client_Survey_Name: "Test 01", Old_Production_Client_Name: "test", Old_Production_Division_Name: "test", Dialing_Form: "Not tested in new system.", Alert_Brand: "test", Alert_Org_Name: "test", Alert_Logically: 0, Alert_Subject: "There shouldn't be alerts for this account!", Alert_To: "test", Alert_CC: "test", Alert_Instructions: "No alerts.", SQL_Alert_Criteria: "0=1", Mailmerge_Template: nil, SQL_Mailmerge_Criteria: nil, Rep_Survey_Note: nil, Alert_Contact_Name: nil, Alert_Contact_Phone: nil, Alert_Contact_EMail: nil, Sunday: 0, Monday: -1, Tuesday: -1, Wednesday: -1, Thursday: -1, Friday: -1, Saturday: 0, Added_At: "2006-03-28 14:56:42", Added_By: "test", Last_Modified_At: "2009-07-03 22:21:40", Last_Modified_By: "test", Caller_Id: "test", Record_Calls: 1>
s.Record_Calls = 0
=> 0
s.save(:keywords => 'LOW_PRIORITY')
ActiveRecord::StatementInvalid: Mysql::Error: Unknown column 'Client,Client_Division,Client_Survey' in 'where clause': UPDATE LOW_PRIORITY Client_Survey_Information SET Alert_Contact_Phone = NULL, Last_Modified_At = '2009-07-03 22:21:40', Rep_Survey_Note = NULL, Alert_Subject = 'There shouldn't be alerts for this account!', Alert_Contact_Name = NULL, Wednesday = -1, Client_Survey_Information_ID = 148, Alert_Org_Name = 'test', Added_At = '2006-03-28 14:56:42', Client_Survey_Name = 'EAP Bench Test 01', Alert_To = 'test', Old_Production_Division_Name = 'test', SQL_Alert_Criteria = '0=1', Alert_Instructions = 'No alerts.', Record_Calls = 0, Friday = -1, Alert_Logically = 0, Dialing_Form = 'Not tested in new system.', Old_Production_Client_Name = 'test', Last_Modified_By = 'test', Monday = -1, Sunday = 0, Thursday = -1, Caller_Id = 'test', Alert_Brand = 'test', Tuesday = -1, Mailmerge_Template = NULL, SQL_Mailmerge_Criteria = NULL, Saturday = 0, Alert_CC = 'test', Alert_Contact_EMail = NULL, Added_By = 'test' WHERE Client,Client_Division,Client_Survey = '--- !seq:CompositePrimaryKeys::CompositeIds \n- Test Client\n- Test\n- Test 01\n'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in log' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:inexecute'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:265:in update_sql' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:338:inupdate_sql'
from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/database_statements.rb:49:in update_without_query_dirty' from /usr/local/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract/query_cache.rb:18:inupdate'
from /usr/local/lib/ruby/gems/1.8/gems/ar-extensions-0.9.2/lib/ar-extensions/create_and_update.rb:268:in update' from /usr/local/lib/ruby/gems/1.8/gems/ar-extensions-0.9.2/lib/ar-extensions/create_and_update.rb:229:increate_or_update'
from /usr/local/lib/ruby/gems/1.8/gems/ar-extensions-0.9.2/lib/ar-extensions/create_and_update.rb:206:in `save'

@rl
Copy link

rl commented Jan 22, 2010

If you remove ar-extensions, does the error go away?

@jmartinmmi
Copy link
Author

dyn - I am following the instructions here for loading the CreateAndUpdate extension:
http://snowgiraffe.com/rdocs/ar-extensions/classes/ActiveRecord/Extensions/CreateAndUpdate.html

Although there is a small typo, the require line should be:
require 'ar-extensions/create_and_update/mysql'

I can save the record fine before loading the extension. If the extension is loaded, the record will not save if any keyword is passed. If there is no keyword, the record saves.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants