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

Ignoring primary key fields in toObject doesn't work #644

Closed
thekevinbrown opened this issue Jul 7, 2020 · 1 comment
Closed

Ignoring primary key fields in toObject doesn't work #644

thekevinbrown opened this issue Jul 7, 2020 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@thekevinbrown
Copy link
Contributor

Describe the bug

  1. Have some entity with an id field.
  2. Call toObject(['id']).
  3. Serialised object still has id field.

Stack trace
This comes from here:

The ignoreFields variable is only checked for non primary key fields.

Expected behavior
It's sometimes nice to omit a primary key when serialising an object. Right now our workaround is:

const obj = whatever.toObject(['other', 'properties']);
delete obj.id;
return obj;

Additional context
N/A

Versions

Dependency Version
node any
typescript any
mikro-orm 3.6.15
your-driver Postgres, any
@thekevinbrown thekevinbrown added the bug Something isn't working label Jul 7, 2020
B4nan added a commit that referenced this issue Jul 19, 2020
@B4nan
Copy link
Member

B4nan commented Jul 19, 2020

Closing as fixed in v4, will be part of alpha 6.

@B4nan B4nan closed this as completed Jul 19, 2020
B4nan added a commit that referenced this issue Aug 2, 2020
B4nan added a commit that referenced this issue Aug 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants