From f7b3a473a995c5f5412fff4658f234ea5e8c9bd7 Mon Sep 17 00:00:00 2001 From: "J. King" Date: Wed, 3 Feb 2021 14:20:34 -0500 Subject: [PATCH] Clarify ordering syntax rationale --- lib/Db/Driver.php | 4 ++-- tests/cases/Db/BaseDriver.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/Db/Driver.php b/lib/Db/Driver.php index cc522dc..09f16e7 100644 --- a/lib/Db/Driver.php +++ b/lib/Db/Driver.php @@ -75,8 +75,8 @@ interface Driver { * - "nocase": the name of a general-purpose case-insensitive collation sequence * - "like": the case-insensitive LIKE operator * - "integer": the integer type to use for explicit casts - * - "asc": ascending sort order - * - "desc": descending sort order + * - "asc": ascending sort order when dealing with nulls + * - "desc": descending sort order when dealing with nulls */ public function sqlToken(string $token): string; diff --git a/tests/cases/Db/BaseDriver.php b/tests/cases/Db/BaseDriver.php index f47bcf0..e34cf65 100644 --- a/tests/cases/Db/BaseDriver.php +++ b/tests/cases/Db/BaseDriver.php @@ -394,7 +394,7 @@ abstract class BaseDriver extends \JKingWeb\Arsse\Test\AbstractTest { $this->assertSame("Z", $this->drv->query("SELECT 'Z' collate $nocase")->getValue()); $this->assertSame("Z", $this->drv->query("SELECT 'Z' where 'Z' $like 'z'")->getValue()); $this->assertEquals(1, $this->drv->query("SELECT CAST((1=1) as $integer)")->getValue()); - $this->assertEquals([null, 1], array_column($this->drv->query("SELECT 1 as t union select null as t order by t $asc")->getAll(), "t")); - $this->assertEquals([1, null], array_column($this->drv->query("SELECT 1 as t union select null as t order by t $desc")->getAll(), "t")); + $this->assertEquals([null, 1, 2], array_column($this->drv->query("SELECT 1 as t union select null as t union select 2 as t order by t $asc")->getAll(), "t")); + $this->assertEquals([2, 1, null], array_column($this->drv->query("SELECT 1 as t union select null as t union select 2 as t order by t $desc")->getAll(), "t")); } }