classUpsertComparison
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 TableDefinitionMethods§
public function __construct(private UpsertNumber $numbers = new \ZtdQuery\Shadow\Mutation\Upsert\UpsertNumber())Parameters
$numbers | UpsertNumber | Reads a value as the number it stands for |
Test cases 15
UpsertComparisonTest::testEqualAnswersWhetherTheTwoAreTheSamecoversUpsertComparisonTest::testGreaterAnswersWhetherTheLeftOrdersLastcoversUpsertComparisonTest::testGreaterOrEqualAlsoHoldsWhereTheTwoOrderTogethercoversUpsertComparisonTest::testLessAnswersWhetherTheLeftOrdersFirstcoversUpsertComparisonTest::testLessOrEqualAlsoHoldsWhereTheTwoOrderTogethercoversUpsertComparisonTest::testNotEqualAnswersWhetherTheTwoDiffercoversUpsertComparisonTest::testOfIsUnknownWhenEitherSideIscoversUpsertComparisonTest::testOfOrdersNumbersWrittenAsTextAsNumbersToocoversUpsertComparisonTest::testOfOrdersTwoNumbersAsNumberscoversUpsertComparisonTest::testOfOrdersTwoPiecesOfTextAsTextcoversUpsertComparisonTest::testOfRefusesANumberAgainstTextcoversUpsertComparisonTest::testOfRefusesTextAgainstANumbercoversUpsertComparisonTest::testTextKeepsTextAsItIscoversUpsertComparisonTest::testTextRefusesAValueWithNoTextFormcoversUpsertComparisonTest::testTextWritesABooleanTheWayADatabaseComparesItcovers
Calls 1
- new UpsertNumber line 25
public function of(mixed $left, mixed $right): int|nullAnswers how two values order against each other.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
int|null Negative, zero or positive, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 12
UpsertComparisonTest::testEqualAnswersWhetherTheTwoAreTheSamecoversUpsertComparisonTest::testGreaterAnswersWhetherTheLeftOrdersLastcoversUpsertComparisonTest::testGreaterOrEqualAlsoHoldsWhereTheTwoOrderTogethercoversUpsertComparisonTest::testLessAnswersWhetherTheLeftOrdersFirstcoversUpsertComparisonTest::testLessOrEqualAlsoHoldsWhereTheTwoOrderTogethercoversUpsertComparisonTest::testNotEqualAnswersWhetherTheTwoDiffercoversUpsertComparisonTest::testOfIsUnknownWhenEitherSideIscovers and callsUpsertComparisonTest::testOfOrdersNumbersWrittenAsTextAsNumbersToocovers and callsUpsertComparisonTest::testOfOrdersTwoNumbersAsNumberscovers and callsUpsertComparisonTest::testOfOrdersTwoPiecesOfTextAsTextcovers and callsUpsertComparisonTest::testOfRefusesANumberAgainstTextcovers and callsUpsertComparisonTest::testOfRefusesTextAgainstANumbercovers and calls
Called from 6
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertComparison::equal() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertComparison.php:97
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertComparison::notEqual() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertComparison.php:114
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertComparison::less() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertComparison.php:131
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertComparison::lessOrEqual() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertComparison.php:148
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertComparison::greater() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertComparison.php:165
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertComparison::greaterOrEqual() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertComparison.php:182
Calls 4
- method-call UpsertNumber::isNumeric() line 44
- new UnsupportedSqlException line 46
- method-call UpsertNumber::of() line 52
- method-call UpsertComparison::text() line 58
public function text(mixed $value): stringReads 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
$value | mixed | Value to read |
Returns
string The text it stands forThrows
UnsupportedSqlException When the value has no text formTest cases 4
UpsertComparisonTest::testOfOrdersTwoPiecesOfTextAsTextcoversUpsertComparisonTest::testTextKeepsTextAsItIscovers and callsUpsertComparisonTest::testTextRefusesAValueWithNoTextFormcovers and callsUpsertComparisonTest::testTextWritesABooleanTheWayADatabaseComparesItcovers and calls
Called from 1
Calls 3
- function-call
is_stringline 75 - function-call
is_boolline 78 - new UnsupportedSqlException line 82
public function equal(mixed $left, mixed $right): bool|nullReports whether two values are the same.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
bool|null Whether they are, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 1
UpsertComparisonTest::testEqualAnswersWhetherTheTwoAreTheSamecovers and calls
Called from 1
Calls 1
- method-call UpsertComparison::of() line 97
public function notEqual(mixed $left, mixed $right): bool|nullReports whether two values differ.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
bool|null Whether they do, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 1
UpsertComparisonTest::testNotEqualAnswersWhetherTheTwoDiffercovers and calls
Called from 1
Calls 1
- method-call UpsertComparison::of() line 114
public function less(mixed $left, mixed $right): bool|nullReports whether the left value orders before the right.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
bool|null Whether it does, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 1
UpsertComparisonTest::testLessAnswersWhetherTheLeftOrdersFirstcovers and calls
Called from 1
Calls 1
- method-call UpsertComparison::of() line 131
public function lessOrEqual(mixed $left, mixed $right): bool|nullReports whether the left value orders before the right, or with it.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
bool|null Whether it does, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 1
Called from 1
Calls 1
- method-call UpsertComparison::of() line 148
public function greater(mixed $left, mixed $right): bool|nullReports whether the left value orders after the right.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
bool|null Whether it does, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 1
UpsertComparisonTest::testGreaterAnswersWhetherTheLeftOrdersLastcovers and calls
Called from 1
Calls 1
- method-call UpsertComparison::of() line 165
public function greaterOrEqual(mixed $left, mixed $right): bool|nullReports whether the left value orders after the right, or with it.
Parameters
$left | mixed | Left operand |
$right | mixed | Right operand |
Returns
bool|null Whether it does, or null when either is unknownThrows
UnsupportedSqlException When one side is a number and the other is notTest cases 1
Called from 1
Calls 1
- method-call UpsertComparison::of() line 182
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
UpsertComparisonTest::testEqualAnswersWhetherTheTwoAreTheSamecovers and callsUpsertComparisonTest::testGreaterAnswersWhetherTheLeftOrdersLastcovers and callsUpsertComparisonTest::testGreaterOrEqualAlsoHoldsWhereTheTwoOrderTogethercovers and callsUpsertComparisonTest::testLessAnswersWhetherTheLeftOrdersFirstcovers and callsUpsertComparisonTest::testLessOrEqualAlsoHoldsWhereTheTwoOrderTogethercovers and callsUpsertComparisonTest::testNotEqualAnswersWhetherTheTwoDiffercovers and callsUpsertComparisonTest::testOfIsUnknownWhenEitherSideIscovers and callsUpsertComparisonTest::testOfOrdersNumbersWrittenAsTextAsNumbersToocovers and callsUpsertComparisonTest::testOfOrdersTwoNumbersAsNumberscovers and callsUpsertComparisonTest::testOfOrdersTwoPiecesOfTextAsTextcovers and callsUpsertComparisonTest::testOfRefusesANumberAgainstTextcovers and callsUpsertComparisonTest::testOfRefusesTextAgainstANumbercovers and callsUpsertComparisonTest::testTextKeepsTextAsItIscovers and callsUpsertComparisonTest::testTextRefusesAValueWithNoTextFormcovers and callsUpsertComparisonTest::testTextWritesABooleanTheWayADatabaseComparesItcovers and calls
Other tests reaching this symbol 7
ConflictSearchTestcallsMutationImpactTestcallsInsertMutationTestcallsUpsertOperatorTestcallsUpsertExpressionTestcallsUpsertMutationTestcallsUpsertUpdateTestcalls
Relations§
Instantiated in 1
Method calls 6
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertOperator::apply() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertOperator.php:66
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertOperator::apply() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertOperator.php:67
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertOperator::apply() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertOperator.php:68
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertOperator::apply() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertOperator.php:69
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertOperator::apply() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertOperator.php:70
- method-call ZtdQuery\Shadow\Mutation\Upsert\UpsertOperator::apply() packages/ztd-query-core/src/Shadow/Mutation/Upsert/UpsertOperator.php:71