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

:on_duplicate_key_update results in "PRIMARY KEY must be unique" #12

Open
petercutting opened this issue Nov 19, 2010 · 0 comments
Open

Comments

@petercutting
Copy link

Hi
I have imported data using ar_extensions 0.9.3 into sqlite 1.3.2 with impressive results. Now I want to process that data updating some fields in same table. The table has :id as primary key

  options = {:validate => false, :on_duplicate_key_update => [:x]}
  columns = [ :id,:x]
  igcfs = Igcfile.find(:all)  # get files
  igcfs.each do |igcf|    # for each file
    ps=[]
    igcps = igcf.igcpoint(:all, :order => 'seq_secs')   # get points
    igcps.each do |igcp|          # for each point

process data

      ps<<[igcp.id,igcp.x]         # push data to array
    end
    Igcpoint.import columns, ps, options   # update DB
  end

development.log sais - WARNING: Can't mass-assign these protected attributes: id

I see that this issue turned up a year ago. Not fixed yet?
http://zdennis.lighthouseapp.com/projects/14379/tickets/26-cant-import-protected-attributes

If there is no fix then it looks like a workaroundmight be to create a 2nd unique key and use that instead of :id

Peter

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

1 participant