Fix for count
This commit is contained in:
parent
c4b11afd08
commit
6cddb38290
2 changed files with 19 additions and 0 deletions
|
@ -2751,6 +2751,13 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/documents')
|
|||
|
||||
$filterQueries = Query::groupByType($queries)['filters'];
|
||||
|
||||
// TODO: Remove this when we have a better way to handle nested attribute queries
|
||||
foreach ($filterQueries as $key => $query) {
|
||||
if (\str_contains($query->getAttribute(), '.')) {
|
||||
unset($filterQueries[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($documentSecurity && !$valid) {
|
||||
$documents = $dbForProject->find('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $queries);
|
||||
$total = $dbForProject->count('database_' . $database->getInternalId() . '_collection_' . $collection->getInternalId(), $filterQueries, APP_LIMIT_COUNT);
|
||||
|
|
|
@ -34,6 +34,12 @@ class Filter extends Base
|
|||
|
||||
protected function isValidAttribute($attribute): bool
|
||||
{
|
||||
if (\str_contains($attribute, '.')) {
|
||||
// For relationships, just validate the top level.
|
||||
// Utopia will validate each nested level during the recursive calls.
|
||||
$attribute = \explode('.', $attribute)[0];
|
||||
}
|
||||
|
||||
// Search for attribute in schema
|
||||
if (!isset($this->schema[$attribute])) {
|
||||
$this->message = 'Attribute not found in schema: ' . $attribute;
|
||||
|
@ -49,6 +55,12 @@ class Filter extends Base
|
|||
return false;
|
||||
}
|
||||
|
||||
if (\str_contains($attribute, '.')) {
|
||||
// For relationships, just validate the top level.
|
||||
// Utopia will validate each nested level during the recursive calls.
|
||||
$attribute = \explode('.', $attribute)[0];
|
||||
}
|
||||
|
||||
$attributeSchema = $this->schema[$attribute];
|
||||
|
||||
if (count($values) > $this->maxValuesCount) {
|
||||
|
|
Loading…
Reference in a new issue