Skip to content
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

ID in included resources are being populated with the pivot table id instead of the actual resource id #111

Closed
javis opened this issue Oct 9, 2018 · 10 comments
Labels
bug Something isn't working

Comments

@javis
Copy link

javis commented Oct 9, 2018

somewhere between version "1.9.0" and latest versions this behavior changed.
In version 1.9.0, if you request a with a included collection of models, the id of these models will be correct, in latest version, it will be filled with the pivot id instead of the original model.

@ce-brex
Copy link
Contributor

ce-brex commented Oct 9, 2018

Ran into a similar issue where pivot attributes were now being returned with models which is new. Look like the fix fields option (SELECT * FROM table instead of SELECT table.* FROM table) change in 1.11 causes it.

@ce-brex
Copy link
Contributor

ce-brex commented Oct 9, 2018

This also causes issues when a model's table and pivot table have fields with the same name and using defaultSort().

In my case, both the model's table and pivot table had created_at fields, and I default sort by -created_at. Downgrading to 1.10.4 fixed both issues.

@ce-brex
Copy link
Contributor

ce-brex commented Oct 9, 2018

Chaining ->select('<table>.*') on the QueryBuilder solves the issue in the latest version, but seems like more of a workaround to me.

@AlexVanderbist
Copy link
Member

Could this be the same issue as #118? A fix for that one was tagged a couple of minutes ago in 1.11.2. Can you please check if the issue is still there on that version?

@AlexVanderbist AlexVanderbist added the bug Something isn't working label Oct 30, 2018
@ce-brex
Copy link
Contributor

ce-brex commented Nov 6, 2018

@AlexVanderbist I think that fix may solve this issue as well, I noticed the commit but haven't had time to test it.

@javis
Copy link
Author

javis commented Nov 9, 2018

I will test the new version soon

@ce-brex
Copy link
Contributor

ce-brex commented Dec 7, 2018

Just got around to retesting this, and it seems my issue is still exists. Pivot table fields are being combined with the main table fields and causing them to be overwritten and/or conflict.

@keepwn
Copy link

keepwn commented Dec 19, 2018

The bug still in 1.12.0,i only can using QueryBuilder::for($user->posts()->select('posts.*')->getQuery()) to temporary fix it.

@AlexVanderbist
Copy link
Member

Hi guys, can you check if the bug persists in 1.13.0? If it does, please PR a failing test and I'll take a look at it there :) Thanks

@saeidee
Copy link

saeidee commented Apr 24, 2019

Still, I am facing the same problem! :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants