Pass attribute to select validator
This commit is contained in:
parent
c310434eeb
commit
947ad20bad
3 changed files with 5 additions and 2 deletions
|
@ -62,12 +62,12 @@ class Base extends Queries
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$validators = [
|
$validators = [
|
||||||
new Select(),
|
|
||||||
new Limit(),
|
new Limit(),
|
||||||
new Offset(),
|
new Offset(),
|
||||||
new Cursor(),
|
new Cursor(),
|
||||||
new Filter($attributes),
|
new Filter($attributes),
|
||||||
new Order($attributes),
|
new Order($attributes),
|
||||||
|
new Select($attributes),
|
||||||
];
|
];
|
||||||
|
|
||||||
parent::__construct(...$validators);
|
parent::__construct(...$validators);
|
||||||
|
|
|
@ -61,7 +61,7 @@ class Filter extends Base
|
||||||
|
|
||||||
foreach ($values as $value) {
|
foreach ($values as $value) {
|
||||||
$condition = match ($attributeType) {
|
$condition = match ($attributeType) {
|
||||||
Database::VAR_RELATIONSHIP => true, // Todo: ?
|
Database::VAR_RELATIONSHIP => true,
|
||||||
Database::VAR_DATETIME => gettype($value) === Database::VAR_STRING,
|
Database::VAR_DATETIME => gettype($value) === Database::VAR_STRING,
|
||||||
default => gettype($value) === $attributeType
|
default => gettype($value) === $attributeType
|
||||||
};
|
};
|
||||||
|
@ -91,6 +91,7 @@ class Filter extends Base
|
||||||
// Validate method
|
// Validate method
|
||||||
$method = $query->getMethod();
|
$method = $query->getMethod();
|
||||||
$attribute = $query->getAttribute();
|
$attribute = $query->getAttribute();
|
||||||
|
|
||||||
switch ($method) {
|
switch ($method) {
|
||||||
case Query::TYPE_EQUAL:
|
case Query::TYPE_EQUAL:
|
||||||
case Query::TYPE_NOTEQUAL:
|
case Query::TYPE_NOTEQUAL:
|
||||||
|
|
|
@ -41,6 +41,8 @@ class Select extends Base
|
||||||
|
|
||||||
foreach ($query->getValues() as $attribute) {
|
foreach ($query->getValues() as $attribute) {
|
||||||
if (\str_contains($attribute, '.')) {
|
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];
|
$attribute = \explode('.', $attribute)[0];
|
||||||
}
|
}
|
||||||
if (!isset($this->schema[$attribute]) && $attribute !== '*') {
|
if (!isset($this->schema[$attribute]) && $attribute !== '*') {
|
||||||
|
|
Loading…
Reference in a new issue