- Set ID as a bigint by default now.

- EntityCollection now transforms array received from append() into entity and then append them.
- Corrected a big bug within QueryBuilder which was missed when it was made compatible with MSSQL.
This commit is contained in:
Dave Mc Nicoll committed 2020-12-04 13:21:59 -05:00
1 parent f74d1907d9
commit 9e84bd3536
3 files changed
+30 -14

No files matched your search

+23 -7
View File
@@ -221,19 +221,35 @@ class EntityCollection extends \ArrayObject {
public function fromArray(array $datasets, ? string /*stringable*/ $entityClass = null) : self
{
if ( ! ($this->entityClass || $entityClass) ) {
throw new \Exception("An entity class name must be provided to be instanciated and populated before insertion into this collection.");
}
$className = $entityClass ?: $this->entityClass;
foreach($datasets as $dataset) {
$this->append( (new $className() )->fromArray($dataset) );
$this->append( $this->arrayToEntity($dataset, $entityClass) );
}
return $this;
}
public function arrayToEntity(array $dataset, ? string /*stringable*/ $entityClass = null) : object
{
if ( ! ($this->entityClass || $entityClass) ) {
throw new \Exception("An entity class name must be provided to be instanciated and populated before insertion into this collection.");
}
$className = $this->entityClass;
return ( new $className() )->fromArray($dataset);
}
public function append($value) : void
{
if ( is_array($value) ) {
$this->append( $this->arrayToEntity($value) );
}
else {
parent::append($value);
}
}
public function mergeWith( /*array|EntityCollection*/ $datasets ) : self
{
if ( is_object($datasets) ) {