Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique ID enforcement? #685

Open
artificial-aidan opened this issue Nov 21, 2023 · 6 comments
Open

Unique ID enforcement? #685

artificial-aidan opened this issue Nov 21, 2023 · 6 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@artificial-aidan
Copy link
Contributor

I'm using @@id to set a field as the ID, but prismock lets me create multiple objects with the same ID. Is this expected? I couldn't find anywhere in the code that would enforce that.

@morintd
Copy link
Owner

morintd commented Nov 21, 2023

Hello @artificial-aidan , there is indeed no mechanism that prevents you from using the same ID multiple times. More generally, errors are not yet implemented.

Now that Prismock is stable enough IMO, I'm starting to think about introducing those mechanisms. I might do so after the current issues get fixed.

@charlesilieff
Copy link

I am interested in the Prismock project, and I noticed the recent issue raised by @artificial-aidan. I was wondering if you have plans to introduce such a mechanism soon.

If you do not have plans to implement this feature in the near future, I would be interested in contributing to the project by implementing it myself. I believe that enforcing ID uniqueness is important for ensuring data integrity, and I would be excited to help improve Prismock in this way.

@sledorze
Copy link

@morintd Hello, interested also in this library, if you may give some directions, maybe we can help?

@morintd morintd closed this as completed Apr 27, 2024
@morintd morintd reopened this Apr 27, 2024
@morintd
Copy link
Owner

morintd commented Apr 27, 2024

Hello @charlesilieff , @sledorze , the search part of @@id is now implemented thanks to @bertrand-sifre but not uniqueness. If you are interested in implementing the feature, feel free to submit a PR 🙏

@thw0rted
Copy link

thw0rted commented Jun 10, 2024

Would it make sense to implement (errors for violating) @unique at the same time? I'm not sure how the behavior differs between those, under the hood.

@morintd morintd added help wanted Extra attention is needed enhancement New feature or request labels Jun 14, 2024
@thw0rted
Copy link

After #1105 was merged, I was expecting baz.create({data: {fooId, barId}}) to fail when creating a record that links to the ID of a "foo" or "bar" that doesn't exist. I see now that the PR didn't update the "create" delegate so I'm guessing more changes will be needed to support that kind of foreign key check. Does that still fit under the spirit of this ticket, or is a new ticket required?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

5 participants