-
-
Notifications
You must be signed in to change notification settings - Fork 189
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
toJSON fix #211
toJSON fix #211
Conversation
src/Lucid/Model/index.js
Outdated
@@ -408,6 +408,8 @@ class Model extends BaseModel { | |||
static async create (payload, trx) { | |||
const modelInstance = new this() | |||
modelInstance.fill(payload) | |||
modelInstance.$visible = this.visible |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be moved to _instantiate
method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And will be nice to have a small test around it
Done - please also review the refactoring in |
src/Lucid/Model/index.js
Outdated
this.$frozen = false | ||
this.$visible = null | ||
this.$hidden = null | ||
super._instantiate() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I am not sure why I even had to instantiate
methods at first place. Also I believe it's find to have $visible
and $hidden
properties on the BaseModel itself and simply remove _instantiate
from here.
Rest all looks good to me. Lemme know when to make that final change and we move it to develop |
Done. FYI Ready to merge. |
Thanks @benallfree. Also you can please start using https://github.com/commitizen/cz-cli. It is something we use for generating consistent commit messages. |
Fix for #210
This feels kind of hacky. The central problem is that Lucid doesn't know how to instantiate a new model. It's done one way in
QueryBuilder
, another way increate()
, and a third way innewUp()
Suggestions?