Hi,

I just installed views 2.0beta4 and wanted to preview the glossary view that comes with the package.

Result:
(I replaced the filesystem path to my drupal installation from the messages by "...")

* warning: pg_query() [function.pg-query]: Query failed: ERROR: function left(character varying, integer) does not exist at character 30 HINT: No function matches the given name and argument types. You may need to add explicit type casts. in .../includes/database.pgsql.inc on line 138.
* user warning: query: SELECT COUNT(*) FROM (SELECT LEFT(node.title, 1) AS title_truncated, COUNT(node.nid) AS num_records FROM node node GROUP BY title_truncated ORDER BY title_truncated ASC ) AS count_alias in .../modules/views/includes/view.inc on line 613.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: function left(character varying, integer) does not exist at character 8 HINT: No function matches the given name and argument types. You may need to add explicit type casts. in .../includes/database.pgsql.inc on line 138.
* user warning: query: SELECT LEFT(node.title, 1) AS title_truncated, COUNT(node.nid) AS num_records FROM node node GROUP BY title_truncated ORDER BY title_truncated ASC LIMIT 36 OFFSET 0 in.../modules/views/includes/view.inc on line 638.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: function left(character varying, integer) does not exist at character 236 HINT: No function matches the given name and argument types. You may need to add explicit type casts. in.../includes/database.pgsql.inc on line 138.
* user warning: query: SELECT COUNT(*) FROM (SELECT node.nid AS nid, node.title AS node_title, users.name AS users_name, users.uid AS users_uid, node.changed AS node_changed FROM node node INNER JOIN users users ON node.uid = users.uid WHERE LEFT(node.title, 1) = 'a' ORDER BY node_title ASC ) AS count_alias in .../modules/views/includes/view.inc on line 613.
* warning: pg_query() [function.pg-query]: Query failed: ERROR: function left(character varying, integer) does not exist at character 214 HINT: No function matches the given name and argument types. You may need to add explicit type casts. in .../includes/database.pgsql.inc on line 138.
* user warning: query: SELECT node.nid AS nid, node.title AS node_title, users.name AS users_name, users.uid AS users_uid, node.changed AS node_changed FROM node node INNER JOIN users users ON node.uid = users.uid WHERE LEFT(node.title, 1) = 'a' ORDER BY node_title ASC LIMIT 36 OFFSET 0 in .../modules/views/includes/view.inc on line 638.

SELECT node.nid AS nid,
   node.title AS node_title,
   users.name AS users_name,
   users.uid AS users_uid,
   node.changed AS node_changed
 FROM node node 
 INNER JOIN users users ON node.uid = users.uid
 WHERE LEFT(node.title, 1) = 'a'
   ORDER BY node_title ASC

See attached patch that seems to fix this for postgres (Tested with 8.2)

Fixed SQL code for postgres:

SELECT node.nid AS nid,
   node.title AS node_title,
   users.name AS users_name,
   users.uid AS users_uid,
   node.changed AS node_changed
 FROM node node 
 INNER JOIN users users ON node.uid = users.uid
 WHERE SUBSTR(node.title, 1, 1) = 'a'
   ORDER BY node_title ASC
CommentFileSizeAuthor
argument.handlers.inc_.diff.txt748 bytesmschiff

Comments

mschiff’s picture

Additional Note:

I did not check whether there is a SUBSTR() function in mysql. If there is one, this code maybe can be changed to use only SUBSTR() and we can kick out that case{} statement that I introduced to simplify the code again...

merlinofchaos’s picture

Status: Needs review » Fixed

Yes, substr() exists in both. Committed, without the case. Thanks!

Anonymous’s picture

Status: Fixed » Closed (fixed)

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