1
0
Fork 0
mirror of synced 2024-10-04 12:15:14 +13:00

Fix for count

This commit is contained in:
Jake Barnby 2023-03-24 20:30:41 +13:00
parent c4b11afd08
commit 6cddb38290
No known key found for this signature in database
GPG key ID: C437A8CC85B96E9C
2 changed files with 19 additions and 0 deletions

View file

@ -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);

View file

@ -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) {