From 3a8c56acc4430547efe9cdadc32c706d1bed6a99 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Fri, 1 Jul 2011 13:35:43 +0200 Subject: [PATCH] Postgres needs a VARCHAR cast, which MySQL doesn't understand, of course. *sigh* --- src/IDF/Views/Issue.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/IDF/Views/Issue.php b/src/IDF/Views/Issue.php index 297e02f..9c749af 100644 --- a/src/IDF/Views/Issue.php +++ b/src/IDF/Views/Issue.php @@ -747,7 +747,13 @@ class IDF_Views_Issue else { // ID-based search if (is_numeric($query)) { - $sql = new Pluf_SQL('project=%s AND CAST(id AS CHAR) LIKE %s', array($prj->id, $query.'%')); + $sql = 'project=%s AND CAST(id AS VARCHAR) LIKE %s'; + // MySQL can't cast to VARCHAR and a CAST to CHAR converts + // the whole number, not just the first digit + if (strtolower(Pluf::f('db_engine')) == 'mysql') { + $sql = 'project=%s AND CAST(id AS CHAR) LIKE %s'; + } + $sql = new Pluf_SQL($sql, array($prj->id, $query.'%')); $tmp = Pluf::factory('IDF_Issue')->getList(array( 'filter' => $sql->gen(), 'order' => 'id ASC'