From 09487f830c9ef34e7c27047d0069b85ad40d5444 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Lorenzo=20Rodr=C3=ADguez?= Date: Wed, 20 Oct 2010 23:29:07 -0430 Subject: [PATCH] Preventing false positive in queries returning fields but havinf Count(*) inside them in DboPostgres --- cake/libs/model/datasources/dbo/dbo_postgres.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cake/libs/model/datasources/dbo/dbo_postgres.php b/cake/libs/model/datasources/dbo/dbo_postgres.php index f3bf33841df..db264f7104c 100644 --- a/cake/libs/model/datasources/dbo/dbo_postgres.php +++ b/cake/libs/model/datasources/dbo/dbo_postgres.php @@ -361,7 +361,7 @@ function fields(&$model, $alias = null, $fields = array(), $quote = true) { } $count = count($fields); - if ($count >= 1 && strpos($fields[0], 'COUNT(*)') === false) { + if ($count >= 1 && !preg_match('/^\s*COUNT\(/', $fields[0])) { $result = array(); for ($i = 0; $i < $count; $i++) { if (!preg_match('/^.+\\(.*\\)/', $fields[$i]) && !preg_match('/\s+AS\s+/', $fields[$i])) {