[web2py] Re: Changing an id... could it be really bad?
If the id in the link the 11 or 12 is then used to reference an id in the database which is an id field in the DAL definition sense then the database engine will usually block you. The id field at the database level is meant to be a non repeating key so reuse of an id numeric value is discouraged and most often prevented by the database engine. Having said that many databases allow for a way around that - look at the output of mysqldump or pg_dump if you happen to use MySQL or PostgreSQL and you will see they use special commands to defeat the autonumber or sequence feature while loading the data. The problem of course with disabling autonumber fields and updating is this possibly forms a relation to foreign keys in other tables. If you look at the db.export_to_csv_file and db.import_from_csv_file it will pack the id fields down when you load the exported data back into a database created with tables and relations defined but no data inserted. If you are dependent on your id fields being contiguous in order to create next and previous links then I think you need to reconsider. Perhaps a select of all ids in the table ordered by id, find the one you are currently on in the list and back up one or move forward one and then use that number. Every time you delete there will be a hole in the sequence where that item used to be.
[web2py] Re: Changing an id... could it be really bad?
You want to avoid changing id's if at all possible because it can easily cause the DB to become inconsistent. I suppose in a worse case scenario you might be able to change it with a database tool (there's an SQLite add-on for Firefox). If you move forward, make sure to consider any other references to that record. A redirect might be a better idea.
[web2py] Re: Changing an id... could it be really bad?
I do not understand On May 31, 6:20 am, "Jason (spot) Brower" wrote: > I want to change the id of one of my items to the id of one that I have > deleted to avoid some URL rot. > Basically, I have:http://interestid.com/welcome/default/view_event/12 > and I want it to be:http://interestid.com/welcome/default/view_event/11 > ID 11 is gone now and 12 is the new one. But my link won't work right if > it's not 11. > Can I just update the id to 11 and not worry? > BR, > Jason Brower