Hi Ron,

I added the Biblio: Authors field to a view, and got the following error:

    * 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 ') AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ') AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ',) AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,,) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ',) AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,,) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ') AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ') AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ') AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN () AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ') AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN () AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ',,2866) AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,,,2866) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.
    * 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 ',,2866) AND auth_category=1 ORDER BY bc.rank' at line 3 query: SELECT * FROM drupal_biblio_contributor bc INNER JOIN drupal_biblio_contributor_data bcd ON bc.cid = bcd.cid WHERE vid IN (,,,2866) AND auth_category=1 ORDER BY bc.rank in /usr/local/webapp/phudev.dlcdev.com/sites/all/modules/biblio/views/biblio_handler_field_contributor.inc on line 51.

The first thing I noticed is that empty strings are being passed to the query (WHERE vid IN (,,,2866)). Here's a patch to biblio_handler_field_contributor.inc, which does 2 things:
* Makes sure not to add empty results to the $vids array, and
* Optimizes the query if $vids has only 1 item in the array, to use '=' instead of 'IN'.

It's not as pretty as it could be (ideally the db_query syntax would use %d & '%s' replacements etc), but it's not ugly either - and seems to work for now ;)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

scottrigby’s picture

Assigned: Unassigned » scottrigby
Status: Active » Needs review
FileSize
1.56 KB

patch attached

rjerome’s picture

Thanks Scott,

As you can see, the Views integration is a work is progress, and any fixes/additions/suggestions are welcome!

Ron.

rjerome’s picture

Status: Needs review » Fixed

Forgot to mention that this was committed to CVS,

Ron.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.