Hello,
I have a clean install of D7 with media 7.x-2.x-dev installed and views 7.x-3.x-dev. I can upload, edit and delete files fine using admin/content/files (see attached image 0). So I presume this module words correctly.
However, whenever I use media types something goes wrong with the media browser. When I want to select a file which is already uploaded using the library, it displays "no files available" (see attached image 2). They make use of views for the media browser.
I checked the corresponding view and it gives the following error (see attached image 1):
SQLSTATE[HY000]: General error: 1 ambiguous column name: fid
I don't know how to fix this or if this is actually the reason why it does not work so I thought to ask it here. Does anyone have an idea how to solve this issue?
Thanks,
Chris
P.S. If I should post this somewhere else, let me know.
Comment | File | Size | Author |
---|---|---|---|
media_browser_bug_2.gif | 24.96 KB | chvndb | |
media_browser_bug_1.gif | 58.49 KB | chvndb | |
media_browser_bug_0.gif | 42.04 KB | chvndb |
Comments
Comment #1
chvndb CreditAttribution: chvndb commentedComment #2
Talkless CreditAttribution: Talkless commentedI have same problem in clean Drupal 8 beta 1 installation (SQLite):
In path admin/content/files
Comment #3
guictx CreditAttribution: guictx commentedI'm having the same problem with with Drupal 7.38 with an SQLite database, Views 7.x-3.11 and Media 7.x-2.0-alpha4+37-dev.
Tried latest Views dev and problem persists.
Changing "Use Aggregation" to NO in the Media Browser view solves the problem, but it might bring other issues.
Comment #4
Denes.Szabo CreditAttribution: Denes.Szabo commentedI have same problem with media browser. The Views query is:
I think, the problem is in the "GROUP BY file_managed_timestamp, fid" line, the fid should be file_managed.fid there.
The SQL is ambiguous because of file_managed and file_usage table both contain fid column.
I hope, this little debug helps. (I am trying to fix it.)
Comment #5
Denes.Szabo CreditAttribution: Denes.Szabo commentedI just debugged a little bit on sqlite, seems the file_managed table fid field has an fid alias. It's the same as the file_usage table fid.
The views atomatically generates the group by statement, builds it from field aliases. So the ambiguous fid comes there by this. No way to alter it by views_query_alter().
I tried to force to alter the file_managed fid field alias using an another method , but then the fid column missing from the query - all theming became broken.
So, the possible solution is - disable the aggregation of this view. At least it works, buts maybe there will be duplicated content in the media browser.
I tried the media_browser_plus, with same result, fid in the group by:
Comment #6
Dennis Walgaard CreditAttribution: Dennis Walgaard at Sogeti for RIVM commentedI have the same problem with the 'library' and 'my files' tabs of the media browser not show any files and just shows 'no files available'.
When i run the example in the view Media Browser (media_default) I get the error:
'SQLSTATE[42702]: Ambiguous column: 7 ERROR: column reference "fid" is ambiguous LINE 8: GROUP BY file_managed_timestamp, fid) subquery ^'
When I run the query that is shown in the view in postgres it fails with the same error. On Mysql, the query runs just fine.
The problem is the fid in the GROUP BY statement. This field is present in both file_managed and file_usaged tables which confuses postgres.
When I add a function hook_views_query_alter(&$view, &$query) and debug $query I see that the 'fid' field is added with an alias 'fid'.
I changed the alias with this function:
But this causes problems in template_preprocess_media_views_view_media_browser() in media.views.inc because that function uses the 'fid' field which I just renamed.
So I used a hook_views_pre_render() to put the 'fid' properties back into the results.
And now the files are shown again in the media browser.