October: Pivot data support in deferred binding

Created on 31 Aug 2015  路  15Comments  路  Source: octobercms/october

Is there any way to create relation manager which has some pivot data and works with deffered binding?

Are there any chances for October to support this anytime soon?

Conceptual Enhancement help wanted

Most helpful comment

I'm just dumping some information here I have found while going after a bug. Maybe this comes in handy if someone tackles this issue in the future.

Having a relation widget that is sorted by a pivot data column (pivot[sort_order]) works fine until you set deferredBinding: true on the relation widget's list config:

Column not found: 1054 Unknown column 'pivot_sort_order' in 'order clause'

It essentially boils down to two things:

  1. With deferredBinding set to true, addConstraints is never called on the relation query, which means the JOIN for the pivot table is not added.
  2. If addConstraints would be called correctly, we still would have to add the as pivot_* select statements to the query. They are missing as well because the query is run in orphanMode which results in getAliasedPivotColumns never being called. This means all the SELECT some_pivot_table.sort_order as pivot_sort_order are not added to the query.

The reason these changes were introduced are documented in https://github.com/octobercms/october/issues/1411 and https://github.com/octobercms/library/commit/9af604158c33d8c811bcb241d4a45aafae8666ce.

All 15 comments

I have the same need, but went around it by disabling the field on create (adding a placeholder message that encourages the user to save "soon") and enabling the relation manager on update only.

In the form declaration, it looks something like this:

fieldName@create:
    label: Field Name
    placeholder: Please save the record first (Ctrl+s)
    disabled: true
fieldName@update:
    label: Field Name
    type: partial
    path: field_fieldname

It's not perfect, but this way you can prevent the user generated error.

Thanks for response,

currently I used similar approach.

But this functionality should be supported in future.

Deferred binding doesn't support pivot data at this stage, we may include this feature one day, but not today. For now you can get away with using an intermediary model instead.

Lots of people want this (as noted in #1553, #1803, #2786) so I'll bump up the priority. Again, if anybody wants this done faster, then either post a bounty (put your money where your mouth is :) ) or implement it yourself and make a PR.

Remember, it's just three people at the core of this project, with thousands of developers and users using this platform each wanting their own improvements and each reporting their own issues. This is open source, so you're free to contribute and make the necessary changes to add support yourself.

To echo @LukeTowers' words: The support demand for October is increasing, while the available time the founders & maintainers have to give remains the same. These issues will be handled in time, however there are ways you can help:

  • Submit a pull request that introduces this feature and wait for it to be reviewed
  • Make a financial contribution to the project so we can allocate more time towards making improvements like these that benefit everyone

In the documentation mentioned that we can use deferred binding with pivot data.
Why does this not work and still exists in the documentation? Thanks.

screen

Is there any update about this situation?

@FlusherDock1 nope. Feel free to sponsor the issue or implement support for it yourself and submit a PR :)

What about attach files in pivot models?

This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see action on it, please respond and we will get the ball rolling.

I'm just dumping some information here I have found while going after a bug. Maybe this comes in handy if someone tackles this issue in the future.

Having a relation widget that is sorted by a pivot data column (pivot[sort_order]) works fine until you set deferredBinding: true on the relation widget's list config:

Column not found: 1054 Unknown column 'pivot_sort_order' in 'order clause'

It essentially boils down to two things:

  1. With deferredBinding set to true, addConstraints is never called on the relation query, which means the JOIN for the pivot table is not added.
  2. If addConstraints would be called correctly, we still would have to add the as pivot_* select statements to the query. They are missing as well because the query is run in orphanMode which results in getAliasedPivotColumns never being called. This means all the SELECT some_pivot_table.sort_order as pivot_sort_order are not added to the query.

The reason these changes were introduced are documented in https://github.com/octobercms/october/issues/1411 and https://github.com/octobercms/library/commit/9af604158c33d8c811bcb241d4a45aafae8666ce.

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.
If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.
If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

Keep this opened, it's actually an issue I was investigating.

This issue will be closed and archived in 3 days, as there has been no activity in the last 60 days.
If this issue is still relevant or you would like to see it actioned, please respond and we will re-open this issue.
If this issue is critical to your business, consider joining the Premium Support Program where a Service Level Agreement is offered.

Was this page helpful?
0 / 5 - 0 ratings