Skip to content

Properly store User Subclass in Storage#978

Merged
dplewis merged 6 commits into
masterfrom
subclass-current
Nov 5, 2019
Merged

Properly store User Subclass in Storage#978
dplewis merged 6 commits into
masterfrom
subclass-current

Conversation

@dplewis

@dplewis dplewis commented Nov 4, 2019

Copy link
Copy Markdown
Member

@taivo Let me know if any changes can be made to replicate your issue

@codecov

codecov Bot commented Nov 4, 2019

Copy link
Copy Markdown

Codecov Report

Merging #978 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #978   +/-   ##
=======================================
  Coverage   91.86%   91.86%           
=======================================
  Files          54       54           
  Lines        5086     5086           
  Branches     1146     1147    +1     
=======================================
  Hits         4672     4672           
  Misses        414      414
Impacted Files Coverage Δ
src/ParseUser.js 82.08% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5245daa...7e6d9b4. Read the comment docs.

@dplewis

dplewis commented Nov 5, 2019

Copy link
Copy Markdown
Member Author

@acinader This is the easiest fix I can come up with.

The issue here is that subclass users don't automatically have a className (must be explicitly set or passed in here somehow). The second issue is that even if a className exist, it's hardcoded before it saves to disk.

@dplewis dplewis changed the title Failing test for subclass.current() Properly store User Subclass in Storage Nov 5, 2019

@acinader acinader left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see my comment

Comment thread src/ParseUser.js Outdated
const path = Storage.generatePath(CURRENT_USER_KEY);
const json = user.toJSON();
json.className = '_User';
json.className = user.className || '_User';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about

json.className = this.constructor.name === 'ParseUser' ? '_User' : this.constructor.name;

i think that'll work and then you don't have to worry about setting this.className.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect!

@dplewis dplewis Nov 5, 2019

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like we have a flaky test. I can't restart the build the button is missing, can you?

Edit: Works now

@taivo

taivo commented Nov 5, 2019

Copy link
Copy Markdown

This is good. When you guys have it merged, I can switch my use case to this and test for a few days.

@dplewis
dplewis requested a review from acinader November 5, 2019 14:49
@dplewis
dplewis merged commit d42cd14 into master Nov 5, 2019
@dplewis
dplewis deleted the subclass-current branch November 5, 2019 17:23
dplewis added a commit that referenced this pull request Nov 14, 2019
Revert #978
@dplewis dplewis mentioned this pull request Nov 14, 2019
dplewis added a commit that referenced this pull request Nov 14, 2019
* Fix #992

Revert #978

* remove static ParseUser class name
dplewis added a commit that referenced this pull request Dec 2, 2019
After much discussion the proper way to subclass is a user is `Parse.Object.registerSubclass('_User', CustomUser);`

Revert ##978
@dplewis dplewis mentioned this pull request Dec 2, 2019
davimacedo pushed a commit that referenced this pull request Dec 2, 2019
After much discussion the proper way to subclass is a user is `Parse.Object.registerSubclass('_User', CustomUser);`

Revert ##978
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.

3 participants