-
Notifications
You must be signed in to change notification settings - Fork 78
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
Upsert fails silently in Rails when run with SQlite3 #19
Comments
it should work:
maybe |
Hmm... That doesn't work on my local for some reason. Here is what happens when I run this series of commands:
(nothing gets for the Could this have something to do with the fact that the 'ID' field is an auto incrementing ID #? |
i bet the problem is a non-autoincrement primary key
you should probably either remove that column or (if you really need it) make it auto-increment. if you want to make it auto-increment, you will have to follow the standard sqlite procedure, which is to create a new table with the correct structure and then copy over the data: |
It is auto-incrementing.. or at least it should be. Or does rails handle the auto-increment itself? I assumed that that was the databases responsibility. |
what's the output of |
|
ok, check it out:
wait for it... (i changed
in a nutshell,
thanks to @derekharmel's #15, however, it IS smart enough to discard please let me know if this solves your issue! |
That worked, cheers! Guess it was a matter of those timestamped columns being marked as |
I am facing the same problem. It updates, but does not create new rows. Seems like "INSERT OR IGNORE INTO" statement does not work: Versions:
Rails console logs:
development.log file entries:
|
any chance this is an in-memory database? |
It is not. It actually behaves differently form rails 4.0.2 and 3.2.16. I will be creating a different bug for 4.0.2 with its own test. In rails 3.2.16 (and possibly 3.2.13 which is used by the main creator of this bug):
Lets generate a 3.2.16 application:
Try creating a row, upsert fails silently:
development.log:
Gemfile.lock:
|
I am running on a
rails 3.2.13
application, along withsqlite3 1.3.7
, attempting to useupsert 1.2.0
in my application but it doesn't seem to want to work and I'm stumped as to what I'm doing wrong. Here's what I've done so far:gem 'upsert', '~> 1.2.0'
to my Gemfilerake db:test:prepare
rails c test
, attempt to use upsert:Examining the
log/test.log
here is the output:Any idea what I might be doing wrong?
The text was updated successfully, but these errors were encountered: