-
-
Notifications
You must be signed in to change notification settings - Fork 207
Pass adapterResult to column consume function #1121
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
base: 21.x
Are you sure you want to change the base?
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? |
π 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
adapterResult
from 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