Skip to content
This repository has been archived by the owner on Dec 12, 2021. It is now read-only.

Potential clash between an existing ID and the randomly generated ID #21

Closed
gamov opened this issue Mar 22, 2011 · 3 comments
Closed

Potential clash between an existing ID and the randomly generated ID #21

gamov opened this issue Mar 22, 2011 · 3 comments

Comments

@gamov
Copy link

gamov commented Mar 22, 2011

Hello,
this is more a concern than an issue.

I'm wondering what happens if the ID generated by:
var new_id = new Date().getTime();
content = content.replace(regexp, new_id);
end up being an existing record id in the DB. Wouldn't it be mistakenly erased by this new record?

@ryanb
Copy link
Owner

ryanb commented Mar 26, 2011

That's a good question. I believe it will update the items in the existing record assuming they belong_to the same parent record. I forget if adding alpha characters into a new id will cause any problems. If not it may be worth keeping the new_ prefix that it replaces.

The ID is very large and like I said I think it has to match the same parent, so the chances of there being a conflict are very slim. Still would be nice to fix though.

@ryanb
Copy link
Owner

ryanb commented Mar 26, 2011

prefix new record ids with new_ to ensure there's no conflict with existing records - closed by c3e667f

@ryanb ryanb closed this as completed Mar 26, 2011
@gamov
Copy link
Author

gamov commented Mar 28, 2011

Excellent idea, that's nice to see Rails handling this nicely

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants