Hello,

I added a filter Taxonomy: Term, chose a Vocabulary, Autocomplete, Exposed and then pressed update which resulted in the below user warning.

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT * FROM term_data td WHERE td.tid IN () in /home/abckonec/public_html/beta/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc on line 298.

Screencast of issue appearing: http://www.screencast.com/users/trupal218/folders/Jing/media/0f71421c-19...

An example of what the taxonomy vocabulary looks like (also terms are originally inputted in Japanese):
A
-1
-2
-3
B
-4
-1
C
-5
-1
D
-1
-2
-3
-4
-5

I've testing this filter on Views 2 and it worked fine before I remember. Just added this filter again today with Views 3 and got this result.
Please let me know if more info is needed. Thanks!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Bilmar’s picture

I'm still unable to add a "Taxonomy: Term" filter with any vocabulary (new or old) to my view =/
However, I am able to create a "Taxonomy: Term ID (with depth)" filter.

Please let me know if anyone can give advice on this issue.
Thanks very much in advance!

phpberlin’s picture

hai and hello

i've exact the same problem as trupal218
by uising views and taxonomie filter and autocomplete

user warning: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 1 query: SELECT * FROM term_data td WHERE td.tid IN () in var\www\drupal6\sites\all\modules\views\modules\taxonomy\views_handler_filter_term_node_tid.inc on line 295.

any suggestions?

thnaxx

dawehner’s picture

trupal218: Can you make a step by step report?

Then fixing would be trivial, i think. Thanks!

Bilmar’s picture

FileSize
41.92 KB

Hello,

Please see the screencast that shows issue at http://www.screencast.com/users/trupal218/folders/Jing/media/4818c94d-ca...

Views 6.x-3.x-dev (2010-Mar-09)

Steps to reproduce:
1) I created a new taxonomy vocabulary with default settings
2) I add some terms to the vocabulary (A, B, C, D, E, F)
3) I created a new view (type node in my screencast) and add filter Taxonomy: term
4) I select the taxonomy vocabulary 'example' with autocomplete and make it Exposed
5) press update and live preview will show the warning message

In the screencast the error shows on a brand new view created as well as a existing fully setup view with many fields (my search page)

@dereine - please let me know if this is enough information to troubleshoot this.
I really appreciate your support!

dawehner’s picture

@dereine - please let me know if this is enough information to troubleshoot this.

And i appreciate your incredible awesome bug repots. Compared to nearly every other issue its much much much better. Really you do it perfect.

I reproduced it step by step, but there is still no error. The good thing is that this error messsage can only be seen by the administration. Could you expose the view? Perhaps there is a space or something like this.

Bilmar’s picture

I appreciate your comment! I try my best to provide as much information to you guys =)
I am trying to learn more and more about Drupal, and I apologize for times when my questions are considered very simple from your side.
I know I speak for the whole Drupal community when I say we all appreciate your work very very much!

With further testing of enabling/disabling other modules, I have found the culprit! It was Hierarchical Select Taxonomy Views.
Disabling this submodule of HS makes the errors go away. This use to work before (in Views 2) so I wonder if there is something HS needs to update to work with Views 3? If there is nothing that may come to mind I will route this issue to HS queue and ask Wim Leers for assistance.

Regards

P.S. Wim Leers was the one who introduced me to www.jingproject.com for screencasts. very cool!

dawehner’s picture

Status: Active » Fixed

Oh cool, so this is fixed now.

Bilmar’s picture

Project: Views (for Drupal 7) » Hierarchical Select
Status: Fixed » Active

Hi Wim Leers,

The error shown at #4 is being caused when Hierarchical Select Taxonomy Views is enabled with Views 3. I have also included a screencast. When Hierarchical Select Taxonomy Views is disabled the warning message goes away. Would you kindly look into this warning message?

Please let me know if more information is needed.

Regards

Wim Leers’s picture

Title: taxonomy term filter resulting in user warning: You have an error in your SQL syntax; » HS Taxonomy Views + Views 3 + taxonomy term filter: You have an error in your SQL syntax
Project: Hierarchical Select » Views (for Drupal 7)
Component: Miscellaneous » Code
Assigned: Unassigned » Wim Leers

(Moving back to the Views issue queue temporarily to get some feedback on how to fix this.)

dereine, I have no clue where to begin looking for the cause. Why does a Views plugin that works just fine with Views 2 all of a sudden stop working with Views 3? And especially: how could it cause an SQL error?

The code should read like butter to you: all I do, is subclassing views_handler_filter_term_node_tid. I override 7 methods (it's less than 250 lines of code, with probably over half of it comments). It must be the exposed input handling that has changed and that's therefore triggering this problem — because only when the accept_exposed_input method returns true, Views will alter the query, based on the input set by Hierarchical Select.

I'd appreciate your pointers here :) — I don't think there's Views 2 API -> Views 3 API upgrade documentation available? If there is, I could not find it.

dawehner’s picture

Project: Views (for Drupal 7) » Hierarchical Select

What does your widget return if there is no term selected?

  function admin_summary() {
    // set up $this->value_options for the parent summary
    $this->value_options = array();

    if ($this->value) {
      $result = db_query("SELECT * FROM {term_data} td WHERE td.tid IN ("  . implode(', ', $this->value) . ")");

      while ($term = db_fetch_object($result)) {
        $this->value_options[$term->tid] = $term->name;
      }
    }
    return parent::admin_summary();
  }

I think $this->value is not an array, as views expect it to be. I don't know what the value is here, but it could be a multi-dimensional array.

robby.smith’s picture

subscribing

phantomvish’s picture

subscribing.

arbel’s picture

Version: 6.x-3.x-dev » 6.x-3.1

I have the same issue but with views 2

exposed filter with autocomplete on a taxonomy term id - selecting a simple one level vocabulary that doesn't have HS activated.

when I disable HS the error goes away.

this is very strange since this shouldn't have anything to do with HS.

Idan

thapar’s picture

Priority: Normal » Critical

I would really like to use Hierarchical Select with Views, but unfortunately this means that I will have to disable it to prevent the error.

I should also mention, that I get the error in the same way as the OP, except I am using Autocomplete with Term ID (but also exposed).

Please help! Thanks!

Subscribe?

Wim Leers’s picture

Version: 6.x-3.1 » 6.x-3.5
Status: Active » Postponed (maintainer needs more info)

Does this problem still exist in 3.5?

gianfrasoft’s picture

Yes, I had this problem after setting up the label on a taxonomy views filter made with a HS widget.

Wim Leers’s picture

Priority: Critical » Minor

I don't have time to look into this. I'll happily review & commit a patch that fixes this :)

Not critical, but minor because it appears to bother very few users.

Wim Leers’s picture

FileSize
709 bytes

Regarding #10: $this->value is always an array, since this is the code:

  function admin_summary() {
    $this->value = (array) $this->value;
    return parent::admin_summary();
  }

So, to debug the problem, I'll need some user that is experiencing this problem to 1) install and enable the devel module, 2) apply the attached patch, 3) try to reproduce the problem, 4) report back the output generated by this patch.

ifitri’s picture

Version: 6.x-3.5 » 6.x-3.7

I had the same problem and got two empty arrays on screen.

Array
(
    [0] => 
)
Array
(
    [0] => 
)

So I added the line:

$this->value = $this->value[0];

after the typecast to array that Wim just pointed out in #18.
The errors are gone, all seems to work.

dsbrianwebster’s picture

subscribing +1

1richards’s picture

subscribing.

brunorios1’s picture

subscribing...

gazzur’s picture

I'm using Views 2, HS 6.x-3.7 and Drupal 6.13. #19 fixed the issue for me.

mattew’s picture

Status: Postponed (maintainer needs more info) » Needs review
FileSize
476 bytes

Hi everybody,

Same issue with View2 and Hierarchical Select.

So I just created this patch (in SVN format) related to the #19 tips, wich has fix the problem for me.
Very big thanks to ifitri !!!

Best regards,

stefan.r’s picture

Issue summary: View changes
Status: Needs review » Closed (won't fix)

6.x issue without activity for over 3 years, closing.

Please reopen if this is still an issue in 7.x.