Can't Save Integer Zero to SQLite3 DB

FWIW, I'm using the SQLite3 DB.

I have a table column declared to be of type integer. When I update a record (using ActiveRecord, of course) any changes to any other columns are made perfectly. Changes to this particular column are also made perfectly as long as the new value is not zero. However, if the new value for this column is zero, it is not updated and the old value is retained.

I'm sorry. I seem to be encountering more than my share of bizarre situations lately. Does anyone have any thoughts? Thanks.

         ... doug

FWIW, I'm using the SQLite3 DB.

I have a table column declared to be of type integer. When I update a record (using ActiveRecord, of course) any changes to any other columns are made perfectly. Changes to this particular column are also made perfectly as long as the new value is not zero. However, if the new value for this column is zero, it is not updated and the old value is retained.

What version of rails ? I do recall some bugs with change tracking and setting integer columns to zero.

Fred

What version of rails ?

2.3.2 and it's going to be really difficult for me to alter that. If it's a Rails bug it could be a major problem for me unless I can find a work-around. Thanks for the input.

       ... doug

I just genned a test app with 2.3.2 + SQLite3 having a model with an integer field.

Setting that field to 0 was successful both via rspec test and console .

I would either try to create a minimal test case app that demonstrates the problem you're seeing, or write more tests. Which couldn't hurt, in any case :slight_smile:

FWIW,

> What version of rails ?

2.3.2 and it's going to be really difficult for me to alter that. If it's a Rails bug it could be a major problem for me unless I can find a work-around. Thanks for the input.

the stuff I remember was fixed before then. Is it the assignment that does nothing or the save itself ? Anything peculiar about the code ?

Fred

I just genned a test app with 2.3.2 + SQLite3 having a model with an integer field.

My gosh!! I didn't intend for you to have to go to that extreme. I do sincerely appreciate your investing the time on my behalf.

I swear that what I reported yesterday was the results I was seeing at that time. Today things seem to be a bit different. I have to conclude that maybe I didn't investigate this thoroughly enough yesterday before posting. I really thought that I had.

Today, the problem seems to be totally different. What's happening is that values set in select elements are properly included in the record TO BE saved. However, those values and only those values are not transferred to the new saved record. The new saved record properly reflects any changes to fields which are not associated with select elements. However, new values associated with select elements which are properly set in the record TO BE saved are not saved. Instead the old values are retained.

At this point, I can only conclude that I must have totally mis-read this problem yesterday and somehow interpreted it to be what I reported. I really apologize for that especially since you went to the trouble of genning a test app under my version of Rails in an attempt to reproduce the problem. I am truly embarrassed.

I may have to re-post this "new" problem. Thanks ever so much for your help.

          ... doug

I just genned a test app with 2.3.2 + SQLite3 having a model with an integer field.

My gosh!! I didn't intend for you to have to go to that extreme. I do sincerely appreciate your investing the time on my behalf.

NP, 5 minutes max to create it, write a couple of tests and open up a console to play with. A short break from other stuff. Besides, I'm kinda ADD and -- oh, look, a cat! :slight_smile:

that values set in select elements are properly included in the record TO BE saved. However, those values and only those values are not transferred to the new saved record. The new saved record properly reflects any changes to fields which are not associated with select elements. However, new values associated with select elements which are properly set in the record TO BE saved are not saved.

Yeah, that sounds very odd. See if you can come up with a simple (reproducible) test case.