- A lot of fixes made again in this patch

This commit is contained in:
Dave Mc Nicoll committed 2021-05-24 20:03:38 +00:00
1 parent 4df9ececba
commit 7fb591e1f5
12 files changed
+222 -52

No files matched your search

+9
View File
@@ -150,4 +150,13 @@ trait ConditionTrait
return $this;
}
public function removeQueryFragment(/* Query\Fragment | stringable | array */ $fragment) : self
{
foreach((array) $fragment as $item) {
$this->queryBuilder->removeFragment($item);
}
return $this;
}
}
+6 -2
View File
@@ -9,6 +9,10 @@ use Closure;
class RelationBuilder
{
const SUBQUERY_FIELD_SUFFIX = "%s\$collection";
const JOIN_FIELD_SEPARATOR = "%s\$";
protected Repository $repository;
protected /*object|string*/ $entity;
@@ -152,7 +156,7 @@ class RelationBuilder
}
foreach($data ?: $this->entity->entityLoadedDataset as $key => $value) {
if ( $key === "{$name}\$collection" ) {
if ( $key === sprintf(static::SUBQUERY_FIELD_SUFFIX, $name) ) {
if ($value) {
if ( null === ( $dataset = \json_decode($value, true) ) ) {
throw new \Exception(sprintf("JSON error '%s' from '%s'", \json_last_error_msg(), $value));
@@ -164,7 +168,7 @@ class RelationBuilder
return $entity::entityCollection();
}
}
elseif ( substr($key, 0, $len ) === "{$name}\$" ) {
elseif ( substr($key, 0, $len ) === sprintf(static::JOIN_FIELD_SEPARATOR, $name) ) {
$vars[substr($key, $len)] = $value;
}
}