-
Notifications
You must be signed in to change notification settings - Fork 8
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
Issue with pivot table #4
Comments
Hey, thanks for feedback! It's a longshot, but have you tried to use pivotModel? You should create one and attach to it |
Hi, Thanks for reply, I tried following but didn't work: |
I'm not sure what you're trying to achieve. From the given code I don't see that you're using Could you give a more complete example of your models? Something that would allow me to recreate the problem? Thanks. |
Sorry for late reply. Please check example below in my case: `const Model = use('Model') class GpsDevice extends Model { vehicles() { }` Query: The above query fetching records with deleted mappings in vehiclegpsdevice model. It seems its not checking deleted_at on pivot table. Can you please help me in that. Thanks |
@lokendrajoshi54 thanks for the code example. Could you also post contents of |
Sure @radmen here is content of VehicleGpsdevice Model: class VehicleGpsdevice extends Model { module.exports = VehicleGpsdevice Same issue I faced with withTrashed() method, I'm trying to figure out if I missed anything, if you can tell me it would be helpful. |
Thanks for the code. I'll try to check it tomorrow. |
@lokendrajoshi54 I did some testing with the examples you gave.
adonis-lucid-soft-deletes/test/softDeletes.spec.js Lines 314 to 336 in 5835dd4
There's a problem with applying adonis-lucid-soft-deletes/test/softDeletes.spec.js Lines 339 to 359 in 5835dd4
So, TLDR:
I'll try to verify if issues with |
Hello @radmen Thanks for your reply and looking into issue. Same thing is applicable for withTrashed() method. Is there any way I can help in this? |
In which context does this apply?
First thing we need to determine is whether this is an issue with the package or Lucid. If you think that the problem is with the package you could try writing a test case which fails - this would help me finding the bug,j |
I was able to reproduce the problem on clean Adonis application. Its been reported: adonisjs/lucid#429 |
@radmen Thanks for looking into this. |
@radmen withTrashed() method is not working inside with method. Here is the snippet: |
@lokendrajoshi54 I'm aware of that. In fact it seems that this is something that is not possible in Lucid. I've asked about it, yet without any answer. |
While fetching relations facing issue with pivot table. When I use "whereHas" on model it does not look deleted_at in pivot table. Please check below example:
Route.query().whereHas('regions', (builder) => {
builder.where('regions.id', queryParams.ward_id)
})
there is pivot table "route_regions" which holds "route_id" and "region_id" and for some rows in "route_regions" table there are some entries which have not null value for deleted_at. But above code fetching all records (including relations for which mappings are soft deleted).
I have to add condition for this in every query (Please check below):
Route.query().whereHas('regions', (builder) => {
builder.where('regions.id', queryParams.ward_id)
builder.whereNull('route_regions.deleted_at')
})
Is there anything I missed or Is there any workaround for this problem?
The text was updated successfully, but these errors were encountered: