-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[1.1.2+] belongsToMany relation causes "integrity constraint violation" error (column is ambiguous) #5542
Comments
This restores the previous functionality broken by the previous team Refs octobercms/october#5542
Apologies regarding this. We will get this sorted in v1.1.4 today. Appreciate the detailed report |
Test completed OK
|
This will be fixed in patch release 1.1.4 Thanks for using October CMS 🙏 |
We created a PR that was recently merged into laravel/framework v6.x (laravel/framework#36720) that would theoretically allow the rolled back PR to function. What we are not sure of yet is wether the implemented fix in #4952 was the best road to take. If we override the newPivotQuery method with a join then all methods calling this function will be joining a third table. This may have some unexpected impact that calls for further investigating. |
Cool, overall that is a good improvement to Laravel internals
Correct, the solution increases the surface area of the defined constraints to affect the pivot query, in addition to the relational query. It is asking for trouble for any implementation with even moderate complexity. Taking a look at the original reasoning behind this, it is hard to justify. There are several ways the original reporter could have solved this in their own design, such as using MorphByMany type or use an independent join table for each data type or extending the form query We will leave this out for now. If it comes up again, we can revisit. Thank you for following up |
Vdlp.Acme
(see: https://github.com/vdlp/octobercms-issues/tree/new-pivot-query)Description:
Unfortunately after upgrading to OC version 1.1.2 we ran into multiple issues due to the following accepted PR’s.
Which took us a lot of debugging and resulted in database query errors in multiple projects…
The added function
newPivotQuery
in particular is causing issues: octobercms/library@v1.1.1...v1.1.2#diff-56f77bab4b0aa050a15e11466ccccbe82ce391f7adeed778ddc5c66c41152127R133The
$query
object is extended with a join clause.After
newPivotQuery
where conditions are being added (outside of this function) without fully qualified column names. Which results in an "integrity constraint violation" (ambiguous column name) error.Example table setup:
vdlp_acme_acmes
vdlp_acme_items
vdlp_acme_acme_item
We propose to rollback this breaking change and let it be reviewed in more detail on how to fix the issue properly without too much extending Laravels' framework code.
Steps To Reproduce:
Use October CMS version 1.1.2 (or 1.1.3).
Vdlp.Acme
plugin from https://github.com/vdlp/octobercms-issues/tree/new-pivot-queryplugins/vdlp/acme
.php artisan october:up
php artisan vdlp:acme:test
to run the example code.This is an example, you still need the full example plugin
Vdlp.Acme
(see: https://github.com/vdlp/octobercms-issues/tree/new-pivot-query) for it to run.The text was updated successfully, but these errors were encountered: