Save and Save As doesn't enforce unique name within user's account
For discussion...
Save and Save As don't enforce a unique name within a user's account.
Saving As with the same name is not helpful as it leads to confusion about which project is which. It's okay for a project to be the same name as another but each owned by different people, but within an account, we should require that they be different project names.
Save can be used to store a project with the same name as a completely different project within a user's account by happenstance - viewing another user's project that just happens to be named equivalent to one of yours, then clicking Save. If we enforce unique project names within an account, this behavior of Save needs to be extended to do the same.
Should we let same-named projects existing within a user's account?
Item 1: What name is not unique, user name or project name? I'm assuming that it's the project title (name).
Item 2: The project names have to be distinct within a user's pool of projects. Otherwise, how does the user distinguish between them?
Correct, but there is currently no mechanism for supporting this.
Matthew Matz | STEM/Robotics Educator Parallax Inc. | Direct: 916-625-3019 | www.parallax.com | @M atzElectronics http://twitter.com/MatzElectronics | Licenses http://www.tspc.oregon.gov/lookup_application/LDisplay_Individual.asp?id=07080L3B270
On Wed, Jan 17, 2018 at 11:01 AM, Jim Ewald [email protected] wrote:
Item 1: What name is not unique, user name or project name? I'm assuming that it's the project title (name).
Item 2: The project names have to be distinct within a user's pool of projects. Otherwise, how does the user distinguish between them?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/parallaxinc/BlocklyProp/issues/1359#issuecomment-358407501, or mute the thread https://github.com/notifications/unsubscribe-auth/AS0quI7nT9-0fa6_GaY9M94bS0FRS1cnks5tLkOigaJpZM4Rh0Qx .
Item 1: What name is not unique, user name or project name? I'm assuming that it's the project title (name).
Project Title (name).
Item 2: The project names have to be distinct within a user's pool of projects. Otherwise, how does the user distinguish between them?
My point exactly.
This is easily enforced with a unique key in the project table. However, care must be taken to ensure that there are no duplicate project titles before installing the new key. Once that is in place, the project DAO layer can throw an exception if a project add or update attempts to use an existing project title.
Question: Wouldn't that enforce that the project title is unique across the whole set of projects, instead of just unique across projects owned by the user? That would mean a view project operation followed by a save operation is really always a save as that requires a rename, and similarly a view project details operation followed by a clone operation is also a save as that requires a rename.
The database constraint can be made up of multiple fields. For example, a unique constraint consisting of the userID + project title would ensure that there are no duplicate project titles for any individual user for any create or update operation on the project table.
That's fantastic! So we'd need to also add code to BlocklyProp to trap and handle the specific exception(s) that a DAO collision would cause so it can provide the user with a response like, "You already have a project with the same name. Please enter a unique name and try saving again."
Correct, the DAO layer would throw an exception; the REST interface layer would trap that and respond to the browser with a JSON packet that detailed the error. The browser code would then interrogate the JSON packet and update the UI as needed.