fix(pinia-orm): Improve Date serialization in Model class#1121
Merged
CodeDredd merged 1 commit intoCodeDredd:masterfrom Mar 27, 2023
sergerdn:feat/model-date-serialization-improvements
Merged
fix(pinia-orm): Improve Date serialization in Model class#1121CodeDredd merged 1 commit intoCodeDredd:masterfrom sergerdn:feat/model-date-serialization-improvements
CodeDredd merged 1 commit intoCodeDredd:masterfrom
sergerdn:feat/model-date-serialization-improvements
Conversation
The new check ensures that the value is an instance of Date
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## master #1121 +/- ##
=======================================
Coverage 99.64% 99.64%
=======================================
Files 88 88
Lines 5875 5878 +3
Branches 536 537 +1
=======================================
+ Hits 5854 5857 +3
Misses 19 19
Partials 2 2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report in Codecov by Sentry. |
Owner
|
Thanks for this PR @sergerdn. 🥇 . That's a good notice. |
CodeDredd
approved these changes
Mar 25, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The new check ensures that the value is an instance of
Datein theserializeValue functionofModel.ts.Adding a condition like
if ('toISOString' in value')to check for the existence of a method on an object can lead to issuesinJavaScript because it does not accurately check whether the method actually exists and can be called. This is because objects in JavaScript can have inherited properties, and theinoperator also checks for properties in the object's prototype chain. As a result, using theinoperator to check for the existence of a method on an object can sometimes result in unexpected behaviour.In my personal experience, I had a big headache with the
inoperator inPython, and since then, I have never usedinin any language with similar behaviour. Because it affected performance much and resulted in unexpected outcomes.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/in#Caveats :
The
inoperator returns true if the specified property is in the specified object or its prototype chain.A few examples:
🔗 Linked issue
❓ Type of change
📚 Description
The new check ensures that the value is an instance of Date, that its getTime() method returns a valid number, and that its toISOString() method returns a valid ISO 8601 string.
📝 Checklist