I have two objects in my table, with id 1 and 2. Why mysql save new
object to my table with id=9?
(So, erlier it save objects to the database as id 7 and 8, I was change
them id by hands)
I have two objects in my table, with id 1 and 2. Why mysql save new
object to my table with id=9?
(So, erlier it save objects to the database as id 7 and 8, I was change
them id by hands)
problem has been solved - I’m reboot Ubuntu. But it’s interesting - how
it appeared? May be anybody know?
Misha O. wrote in post #1007057:
I have two objects in my table, with id 1 and 2. Why mysql save new
object to my table with id=9?
Assuming you’re talking about a MySQL auto-increment field this is
perfectly acceptable behavior. You should never rely on auto-incrmenting
fields to be absolutely sequential. The only thing that is important is
that they are unique, which MySQL will enforce.
(So, erlier it save objects to the database as id 7 and 8, I was change
them id by hands)
Do not manipulate auto-incrementing field values manually. If you
absolutely need a field that must be kept sequential you need to
implement that yourself. Make this a separate field from id, which by
default Rails uses for row/object identity.
Thanks
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs