-
-
Notifications
You must be signed in to change notification settings - Fork 3
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
Default values are not overridden when constructing a model #186
Labels
Comments
This is related to #180 as the issue stems from setting default values. |
nandi95
added a commit
to nandi95/framework-1
that referenced
this issue
Jan 27, 2022
This will allow setting up descriptors for default values Resolves upfrontjs#186
7 tasks
7 tasks
nandi95
added a commit
that referenced
this issue
Jan 28, 2022
## Fix * fix(attributes)(**BREAKING CHANGE**): moved constructor logic into `create` * This will allow setting up descriptors for default values * Resolves #186 ### Docs * docs(model): added missing `create` documentation * docs: simplified pagination recipe * docs(model): fixed grammar ### Refactor * refactor(collection): updated `_newInstance` typing to not use any * refactor(relations): moved `relations` into its handling class * refactor(internal): added response handling method overrides ## Chore * chore: incremented package version * chore(deps-dev): updated lint-staged ### Style * style(api-calls): moved method call to new line * style(api-calls): fixed eslint issue * style(api-calls): fixed eslint issue in test ### Continuous Integration * ci: wrapped dotfile in quotes
nandi95
added a commit
that referenced
this issue
Jan 28, 2022
## Fix * fix(attributes)(**BREAKING CHANGE**): moved constructor logic into `create` * This will allow setting up descriptors for default values * Resolves #186 ### Docs * docs(model): added missing `create` documentation * docs: simplified pagination recipe * docs(model): fixed grammar ### Refactor * refactor(collection): updated `_newInstance` typing to not use any * refactor(relations): moved `relations` into its handling class * refactor(internal): added response handling method overrides ## Chore * chore: incremented package version * chore(deps-dev): updated lint-staged ### Style * style(api-calls): moved method call to new line * style(api-calls): fixed eslint issue * style(api-calls): fixed eslint issue in test ### Continuous Integration * ci: wrapped dotfile in quotes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there an existing issue for this?
Search terms
field
property
attribute
default value
constructing
new model
magic access
descriptors
accessor
mutator
constructing
Current Behavior
If a model has default values like so:
when constructing a class with
myAttribute
value passed in as 2new User({ myAttribute: 2 })
key will still be1
.Furthermore, casting and mutators will not work either.
Expected Behavior
Even if there are default values, the attribute should still be set to the passed value when constructing the class.
Environment
Anything else?
This is due to js first constructing the parent class and properties defined in the subclass will only be actually set when it comes to constructing the subclass. By this time the property descriptors have already been set up and now being overwritten.
Workaround
Avoid constructing classes by using the
create
method or construct the class and call thefill
with the intended attributes on the instanceReproduction
No response
The text was updated successfully, but these errors were encountered: