16 private string $fieldName,
17 private string $tableName
23 if ( $value ===
null || is_bool( $value ) ) {
26 throw new \InvalidArgumentException(
'Invalid value for tri-state boolean' );
30 public function evaluate( stdClass $row, $value ): bool {
31 $rowValue = $row->{ $this->fieldName };
32 if ( $rowValue !==
null ) {
33 $rowValue = (bool)$rowValue;
35 return $rowValue === $value;
41 $query->
fields( $this->fieldName );
46 $set = $this->getEnumValues( [
false,
true,
null ] );
47 if ( $set ===
null ) {
49 } elseif ( $set === [] ) {
52 $null = in_array(
null, $set,
true );
53 $false = in_array(
false, $set,
true );
54 $true = in_array(
true, $set,
true );
61 if ( !$true || !$false || $null ) {
63 foreach ( $set as $value ) {
64 $orConds[] = $dbr->
expr( $this->fieldName,
'=', $value );
66 if ( count( $orConds ) > 1 ) {
69 $query->
where( $orConds[0] );