Pass adapterResult to column consume function#1121
Conversation
80c3e8a to
73b3853
Compare
|
@thetutlage Does this explanation make sense? |
|
Hey, can you please also open another PR for the docs? And add some tests as well |
|
Where would you like to see the docs? This is the most relevant section I can find, but it doesn't contain the existing extra arguments (attribute, model). It seems like the sort of thing left for Typescript types to explain. https://lucid.adonisjs.com/docs/models#preparing-and-consuming-columns |
|
Added test coverage |
|
bumping this PR. tests are passing. LMK if/where you would like to see docs |
Yup, let's add it there itself |
|
Can you please run |
|
Hi @thetutlage I ran the formatter and created a new PR for the docs. adonisjs/lucid.adonisjs.com#58 Does this look ok? Are we good to merge this? |
|
Hi @thetutlage just checking in here. The docs and formatting have been addressed as per the comment above. Are we ok to merge this? |
|
This pull request has been marked as stale because it has been inactive for more than 21 days. Please reopen if you still intend to submit this pull request |
|
This pull request has been automatically closed because it has been inactive for more than 4 weeks. Please reopen if you still intend to submit this pull request |
🔗 Linked issue
https://discord.com/channels/423256550564691970/1395127978777772052
Docs update: adonisjs/lucid.adonisjs.com#58
❓ Type of change
📚 Description
Impossible to use other model attributes in consume function.
The consume function signature is
(value, attribute ,model) =>The problem is that since the attributes are parsed and assigned to the model in a random order you can't assume that a certain other attribute has already been assigned to the model, so you can't use other model attributes when consuming an attribute.
I read the lucid source code and there doesn't seem to be any way to access the
adapterResultfrom the consume hook, since it's not a property of the model and only exists in the scope.This seems to be the cleanest way to implement this functionality, since it's backwards compatible
📝 Checklist