Skip to content

Commit 19830b1

Browse files
committed
Record is not empty if constructed from a DataObject
1 parent f0ecaff commit 19830b1

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

Tests/Unit/CursorTest.php

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public function testCursor() : void
3030

3131
foreach ($table->getDataObjectCursor() as $key => $record)
3232
{
33+
$customer = new \Tests\App\Record\Customer($record);
34+
$this->assertFalse($customer->empty(), 'Record constructed from DataObject is empty');
3335
$this->assertEquals($index++, $key, 'DataObjectCursor key is not correct');
3436
$this->assertEquals($index, $record->customer_id, 'DataObjectCursor record is not correct');
3537
$this->assertEquals($index, $record['customer_id'], 'DataObjectCursor array access is not correct');

src/PHPFUI/ORM/Condition.php

+12-12
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
/**
66
* Conditions are used for the WHERE part of the query. Think of each Condition as enclosed in parentheses ().
77
*
8-
* You start with an initial test: Field Operator Value (FOV) tupple.
8+
* You start with an initial test: Field Value Operator (FVO) tupple.
99
*
10-
* You can then add additional FOV tupples with a logical operator (AND, OR, AND NOT, OR NOT) separating the previous FOV tupple.
10+
* You can then add additional FVO tupples with a logical operator (AND, OR, AND NOT, OR NOT) separating the previous FVO tupple.
1111
*
1212
* To add a sub condition in parentheses, add another Condition with the same logical operator separator.
1313
*/
@@ -17,12 +17,12 @@ class Condition implements \Countable, \Stringable
1717
private array $conditions = [];
1818

1919
/**
20-
* Start a Condition with a Field Operator Value (FOV) tupple.
20+
* Start a Condition with a Field Value Operator (FVO) tupple.
2121
*
22-
* Will try to parse FOV from string if $operator is null.
22+
* Will try to parse FVO from string if $operator is null.
2323
*
24-
* @param ?string $field single name (no .) of a field existing the the table. Will try to parse FOV from string if $operator is null.
25-
* @param mixed $value to test field against. Must be string for LIKE operators and an array for IN operators.
24+
* @param ?string $field single name (no .) of a field existing the the table. Will try to parse FVO from string if $operator is null.
25+
* @param mixed $value to test field against. Must be string for LIKE operators and an array for IN operators.
2626
* @param \PHPFUI\ORM\Operator $operator comparision of your choice
2727
*/
2828
public function __construct(?string $field = null, mixed $value = null, \PHPFUI\ORM\Operator $operator = new \PHPFUI\ORM\Operator\Equal())
@@ -90,23 +90,23 @@ public function __toString() : string
9090
}
9191

9292
/**
93-
* Add logical AND between FOV tupples or Condition
93+
* Add logical AND between FVO tupples or Condition
9494
*/
9595
public function and(string | \PHPFUI\ORM\Condition $condition, mixed $value = null, \PHPFUI\ORM\Operator $operator = new \PHPFUI\ORM\Operator\Equal()) : self
9696
{
9797
return $this->add('AND', $condition, $operator, $value);
9898
}
9999

100100
/**
101-
* Add logical AND NOT between FOV tupples or Condition
101+
* Add logical AND NOT between FVO tupples or Condition
102102
*/
103103
public function andNot(string | \PHPFUI\ORM\Condition $condition, mixed $value = null, \PHPFUI\ORM\Operator $operator = new \PHPFUI\ORM\Operator\Equal()) : self
104104
{
105105
return $this->add('AND NOT', $condition, $operator, $value);
106106
}
107107

108108
/**
109-
* @return int the number of FOV tupples in the condition
109+
* @return int the number of FVO tupples in the condition
110110
*/
111111
public function count() : int
112112
{
@@ -116,7 +116,7 @@ public function count() : int
116116
/**
117117
* @return string[] of all the fields used by the condition
118118
*/
119-
public function getFields(?self $condition = null) : array
119+
public function getFields() : array
120120
{
121121
$retVal = [];
122122

@@ -182,15 +182,15 @@ public function getJSON() : string
182182
}
183183

184184
/**
185-
* Add logical OR between FOV tupples or Condition
185+
* Add logical OR between FVO tupples or Condition
186186
*/
187187
public function or(string | \PHPFUI\ORM\Condition $condition, mixed $value = null, \PHPFUI\ORM\Operator $operator = new \PHPFUI\ORM\Operator\Equal()) : self
188188
{
189189
return $this->add('OR', $condition, $operator, $value);
190190
}
191191

192192
/**
193-
* Add logical OR NOT between FOV tupples or Condition
193+
* Add logical OR NOT between FVO tupples or Condition
194194
*/
195195
public function orNot(string | \PHPFUI\ORM\Condition $condition, mixed $value = null, \PHPFUI\ORM\Operator $operator = new \PHPFUI\ORM\Operator\Equal()) : self
196196
{

src/PHPFUI/ORM/Record.php

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ public function __construct(int|array|null|string|\PHPFUI\ORM\DataObject $parame
105105

106106
case \PHPFUI\ORM\DataObject::class:
107107
$this->current = \array_intersect_key($parameter->current, static::$fields);
108+
$this->empty = false;
108109

109110
break;
110111

0 commit comments

Comments
 (0)