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

feat(core): allow for the number zero as a primary key #426

Merged
merged 1 commit into from
Mar 27, 2020

Conversation

pbohnenkamp
Copy link
Contributor

There are some cases where an entity will have a primary key of 0.
Our use case is a table of static statuses that are pervasive
throughout our application. We add the rows when we generate the
schema, not through the ORM. We only want to map relationships
to those statuses with the ORM. Some of these statuses start with
the id of 0 versus 1. Previous to this fix, there were generic
falsy checks that would take a primary key with a value of 0 as
if the primary key was not set. This fix makes those checks
specific for both null and undefined values.

There are some cases where an entity will have a primary key of 0.
Our use case is a table of static statuses that are pervasive
throughout our application. We add the rows when we generate the
schema, not through the ORM. We only want to map relationships
to those statuses with the ORM. Some of these statuses start with
the id of 0 versus 1. Previous to this fix, there were generic
falsy checks that would take a primary key with a value of 0 as
if the primary key was not set. This fix makes those checks
specific for both null and undefined values.
@pbohnenkamp
Copy link
Contributor Author

Apologies for the totally new pull request, after merging all the commits from upstream, I couldn't figure out how to get the change to stay at one commit for the previous pull request.

@B4nan
Copy link
Member

B4nan commented Mar 27, 2020

Thanks!

@B4nan B4nan merged commit 88b979a into mikro-orm:master Mar 27, 2020
@pbohnenkamp
Copy link
Contributor Author

pbohnenkamp commented Mar 27, 2020 via email

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

Successfully merging this pull request may close these issues.

2 participants