From 6365df0d660f12ad54ff80999294035ec38ea168 Mon Sep 17 00:00:00 2001
From: pookey <pookey@625475ce-881a-0410-a577-b389adb331d8>
Date: Sun, 16 Dec 2007 20:12:27 +0000
Subject: [PATCH] refs #681 : adding failing test case

---
 tests/Query/OrderbyTestCase.php | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tests/Query/OrderbyTestCase.php b/tests/Query/OrderbyTestCase.php
index 4c2f54c78..ab041c8bd 100644
--- a/tests/Query/OrderbyTestCase.php
+++ b/tests/Query/OrderbyTestCase.php
@@ -53,4 +53,15 @@ class Doctrine_Query_Orderby_TestCase extends Doctrine_UnitTestCase
 
         $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name, COUNT(p.phonenumber) AS p__0 FROM entity e LEFT JOIN phonenumber p ON e.id = p.entity_id WHERE (e.type = 0) ORDER BY p__0 DESC');
     }
+    /* ticket #681 */
+    public function testOrderByWithCoalesce()
+    {
+        $q = new Doctrine_Query();
+        
+        $q->select('u.name')
+          ->from('User u')
+          ->orderby('COALESCE(u.id, u.name) DESC');
+        // nonesese results expected, but query is syntatically ok.
+        $this->assertEqual($q->getQuery(), 'SELECT e.id AS e__id, e.name AS e__name FROM entity e WHERE (e.type = 0) ORDER BY COALESCE(e__id, e__name) DESC');
+    }
 }