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
Renaming attributes with eager loading returns error #1556
Comments
Aliasing attributes for includes is actually probably not supported at this time, i don't think there's any tests for it or anything like that. |
My solution is adding a getter method to the model :
|
Fixed by #1916 |
What is the version that include this PR? I'm on 1.7.10 and get
when doing Company.find({
where: {company_id: company_id},
attributes: [
['company_max_allowed_user', 'maxUsers']
],
include: [{
model: License, as: 'Licenses',
attributes: [
['license_type', 'type'],
['license_duration', 'duration'],
['license_autorenew', 'autorenew']
],
include: [{
model: Product, as: 'Products',
attributes: [
['product_title','title'],
['product_image','image']
]
}]
}] More useful infos:
|
You can check what tags the commit have, have a look at: 6541fb4 The PR mentioned is only on 2.0.0-dev12 and up. |
It works in almost any case, except when using limit and offset. I found this out today when trying to implement paging. Will dig in the issue deeper to see if I can find out where the alias is used to join instead of the real field name. |
It happens with a findAll that has included models var options = {
attributes: [
['id', 'service_request_id'],
['category_id', 'service_code'],
'status',
['location', 'address'],
['latitude', 'lat'],
['longitude', 'long'],
['enteredDate', 'requested_datetime'],
['lastModified', 'updated_datetime']
],
include: [{
model: models.service,
attributes: ['service_name']
}, {
model: models.issue,
attributes: ['description'],
include: [{
model: models.media
}]
}, {
model: models.person,
attributes: ['firstname', 'middlename', 'lastname'],
include: [{
model: models.department,
attributes: ['name']
}]
}],
order: [
['enteredDate', 'DESC']
],
offset: 0,
limit: 10
};
models.request.findAll(options).then(function(results) {}); |
@milovanderlinden please open a new issue. |
This gives error:
The text was updated successfully, but these errors were encountered: