Browse Source

Clarify ordering syntax rationale

rpm
J. King 3 years ago
parent
commit
f7b3a473a9
  1. 4
      lib/Db/Driver.php
  2. 4
      tests/cases/Db/BaseDriver.php

4
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;

4
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"));
}
}

Loading…
Cancel
Save