1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Clarify ordering syntax rationale

This commit is contained in:
J. King 2021-02-03 14:20:34 -05:00
parent af51377fe9
commit f7b3a473a9
2 changed files with 4 additions and 4 deletions

View file

@ -75,8 +75,8 @@ interface Driver {
* - "nocase": the name of a general-purpose case-insensitive collation sequence * - "nocase": the name of a general-purpose case-insensitive collation sequence
* - "like": the case-insensitive LIKE operator * - "like": the case-insensitive LIKE operator
* - "integer": the integer type to use for explicit casts * - "integer": the integer type to use for explicit casts
* - "asc": ascending sort order * - "asc": ascending sort order when dealing with nulls
* - "desc": descending sort order * - "desc": descending sort order when dealing with nulls
*/ */
public function sqlToken(string $token): string; public function sqlToken(string $token): string;

View file

@ -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' collate $nocase")->getValue());
$this->assertSame("Z", $this->drv->query("SELECT 'Z' where 'Z' $like 'z'")->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(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([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([1, null], array_column($this->drv->query("SELECT 1 as t union select null as t order by t $desc")->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"));
} }
} }