Cache include query not possible ?
I have a query with (INNER JOIN) include models, and when i get data from cache, i get only first level of depth (Model) of my query. Why ?
Model.cache('cache-key').findAll({
...
include: [{
model: Model2,
....
include: [{
model: Model3,
....
}]
}]
Fixed in 2.3.0
@DanielHreben you didn't test the alias at the fields/attributes level ;). It fails.
For example attributes: [['original_field','alias']],
alias field disappear from data when it comes from cache...
In my code:
include: [{
model: ModelToColor,
attributes: ['id'],
as: 'to_color',
required: true,
include: [{
model: Color,
attributes: ['main_hexa'],
required: true,
as: 'color'
}]
}]
=> Works
include: [{
model: ModelToColor,
attributes: [['id', 'node_id']],
as: 'to_color',
required: true,
include: [{
model: Color,
attributes: ['main_hexa'],
required: true,
as: 'color'
}]
}]
DOESN'T when from cache.
cc @SiddhantJ19
@usb248 Could you please submit PR with test case covering this issue?
@usb248 Could you please submit PR with test case covering this issue?
Sorry, i haven't time at the moment :S
Yes. But is it specific to nested include queries? As seen in the example above, we need to fix instance reconstruction. I'll look into it. Also I suggest since the original issue wasn't this, can this issue be raised separately while closing the original issue. Thanks.
the bug was discovered on a request with joins but I think that the problem isn't specific to this type of query ...