final class UpsertComparison

Compares two values the way a database does it.

Numbers are compared as numbers and text as text; comparing one against the other is refused rather than guessed at, because which of the two a database would coerce depends on the column types and the collation, neither of which is known here. Null is unknown, so every comparison against it is unknown.

Type Aliases§

RowValue = import from TableDefinition

Methods§

public function of(mixed $left, mixed $right): int|null

Answers how two values order against each other.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

int|null Negative, zero or positive, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 12
Called from 6
Calls 4
public function text(mixed $value): string

Reads a value as the text it stands for.

A boolean is the one non-text value that still has a text form here, because that is the form a database compares it in.

Parameters

$valuemixedValue to read

Returns

string The text it stands for

Throws

UnsupportedSqlException When the value has no text form
Test cases 4
Called from 1
Calls 3
public function equal(mixed $left, mixed $right): bool|null

Reports whether two values are the same.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

bool|null Whether they are, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 1
Called from 1
Calls 1
public function notEqual(mixed $left, mixed $right): bool|null

Reports whether two values differ.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

bool|null Whether they do, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 1
Called from 1
Calls 1
public function less(mixed $left, mixed $right): bool|null

Reports whether the left value orders before the right.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

bool|null Whether it does, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 1
Called from 1
Calls 1
public function lessOrEqual(mixed $left, mixed $right): bool|null

Reports whether the left value orders before the right, or with it.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

bool|null Whether it does, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 1
Called from 1
Calls 1
public function greater(mixed $left, mixed $right): bool|null

Reports whether the left value orders after the right.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

bool|null Whether it does, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 1
Called from 1
Calls 1
public function greaterOrEqual(mixed $left, mixed $right): bool|null

Reports whether the left value orders after the right, or with it.

Parameters

$leftmixedLeft operand
$rightmixedRight operand

Returns

bool|null Whether it does, or null when either is unknown

Throws

UnsupportedSqlException When one side is a number and the other is not
Test cases 1
Called from 1
Calls 1

Private surface 1§

Implementation details, listed for orientation only.

private UpsertNumber $numbers = new \ZtdQuery\Shadow\Mutation\Upsert\UpsertNumber()

Test cases 22§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 15
Other tests reaching this symbol 7

Relations§

Instantiated in 1
Method calls 6
Type declarations 1