Posted by scottrigby on June 15, 2009 at 2:41pm
| Project: | Bibliography Module |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | scottrigby |
| Status: | closed (fixed) |
Issue Summary
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 ;)
Comments
#1
patch attached
#2
Thanks Scott,
As you can see, the Views integration is a work is progress, and any fixes/additions/suggestions are welcome!
Ron.
#3
Forgot to mention that this was committed to CVS,
Ron.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.