Fix query of collection of resource through foreign key when possible, modifies expression.