Installed Drupal 6.1
i18n-6.x-1.x-dev.tar.gz
views-6.x-2.0-alpha3.tar.gz
during creation of view, when a select Preview this error message is show
user warning: Unknown column 'node.language' in 'where clause' query: SELECT COUNT(*) FROM (SELECT node.nid AS nid, node_revisions.body AS node_revisions_body, node_revisions.format AS node_revisions_format, node.created AS node_created, node.status AS node_status, node_revisions.teaser AS node_revisions_teaser, node.title AS node_title, node.type AS node_type FROM node node LEFT JOIN node_revisions node_revisions ON node.vid = node_revisions.vid WHERE ((node.type in ('story'))) ) count_alias WHERE (node.language ='de' OR node.language ='' OR node.language IS NULL) in /var/www/drupal6/trunk/sites/all/modules/views/includes/view.inc on line 510.
I don't know if is due views module, or i18nviews
seems like inner query doesn't pick node.language
i will post this to views issues also
Comments
Comment #1
merlinofchaos commentedThis is i18n's rewrite not being prepared for Views' use of SELECT from (SELECT) which is a brand new feature. Your message indicates you posted in the i18n queue as well; you should reflect that information there so they can adjust their query rewriting to deal with this.
I suspect as Drupal 6 matures, they're going to see a lot more selects with subselects, so they need to be able to cope.
Comment #2
seanrWhat should i18n be doing to fix this? There's been no progress on that. Also, as the post of this there was only a comment for an issue, not an issue of it's own, I move that this be reopened and moved to that project.
Comment #3
seanrMoving to i18n. Currently produces an error and renders all views unsuable on a site with i18n running.
Comment #4
seanrProblem appears to be i18n_db_rewrite_where(), but I have no idea how to fix it.
Comment #5
seanrmore accurate title
Comment #6
jose reyero commentedOk, so this is the offending query (From views view.inc, line 500)
For now I'm just added a preg_match so these queries are not rewritten. It doesn't throw an error anymore, so changed priority to normal, but also language conditions are not applied to these queries so this is still an issue.
However, I see no way to rewrite such a query with db_rewrite_sql and IMHO this needs to be fixed on views module side. This would be the right rewriting code for views.inc. Otherwise I'm afraid all the rewriting modules out there will fail.
Earl, I'm not switching this to back to views module, I don't want this to look like issue ping-pong :-), but I'd appreciate if you could follow up here at least till we decide on which side we need to patch. Thanks.
Comment #7
merlinofchaos commentedcore's db_rewrite_sql handles sub-selects, so you may be able to utilize something there to handle it.
My belief is that this is not going to be isolated. Sub-selects are going to get more common, and they will need to be dealt with.
Comment #8
jose reyero commentedI can't find any place where core handles that.
The fact that views queries work with node_db_rewrite_sql is just because it's not returning any parameter other than 'distinct'.
So far I haven't been able to find any working example of db_rewrite_sql really adding query conditions and subselects. If someone could please point me to one of that...
Comment #9
chx commentedCore has an utterly complex and ugly regexp in db_rewrite_sql (database.inc) which handles subselects.
Comment #10
drewish commentedsubscribing.
Comment #11
jose reyero commented@chx, thanks for the info.
@merlinofchaos, as content language is now a core concept, any plan to add it as a filter provided by views module?
I've been looking at the core part and that code is definitely nothing I'd like to get into :-(. Whatever it seems to be buggy as it is not working for this specific case, unless I'm missing some special rule for these subquery rewriting cases.
About i18n/views, the thing is that we don't really need to rewrite such queries at all, as it should be up to the view definition to set up a language filter or not...
Still unsure whether I should file a core bug for these query rewriting cases not working. Whatever, about i18n, this is fixed, such queries just won't be rewritten (unless we really need it for some other query and someone can tell me how to do it)
Thanks
Comment #12
merlinofchaos commentedI agree, a view filter for determining language is very much the better choice. I'll need to study the data to see where it is (or if you're familiar with it, a quick primer would make my job easier).
I see a 'language' field, I assume that can easily be correllated to global $language->language, so a "filter to current user's language" filter is easy. What is the translate field? Is that a nid? That may not be something I need to worry about right away.
Comment #13
jose reyero commentedSir, here you are the patch for language in views
http://drupal.org/node/238252
(The new version of views looks great btw, I love the whole OO thing :-) )
Comment #14
merlinofchaos commentedQuestion: Do we really have to check for the 'translation' module specifically? It's a core field, I feel uncomfortable even making that check. I don't see any other code that's actually specific to that, and it prevents other modules from utilizing the fields in some manner.
Shouldn't there also be a filter option for "user's current language"?
Otherwise, this is looking like an excellent start. A couple of the function comments show cut & paste issues though =)
Comment #15
merlinofchaos commentedThat comment is on the wrong issueb. Sorry
Comment #16
drewish commentedI don't think this is actually fixed. With HEAD of both i18n and views current error is:
The non-count query is:
On IRC Earl pointed out that views now has a language filter but the problem is that it requires that you explicitly specify a language or expose the filter to the user to select the language. It doesn't honor the user's language or the language specified in the URL.
So it would seem that either:
* views needs to put some kind of marker into the query that i18n can use to know to ignore the query and i18n needs to provide a "smart" language filter that selects the language automagically.
* i18n needs to be smart enough to rewrite the default views queries.
Comment #17
drewish commentedthe hackish work around for this is to just to remove the node limit.
Comment #18
flickerfly commentedsub
Comment #19
drewish commentedi think this is working after all, it turned out that development on i18n was happening in DRUPAL-6 and I was using HEAD.
Comment #20
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.