This commit is contained in:
ArnabChatterjee20k
2025-05-23 14:11:57 +05:30
parent 6ea3593921
commit e586afceb7
3 changed files with 16 additions and 17 deletions
-1
View File
@@ -2053,7 +2053,6 @@ App::get('/v1/databases/:databaseId/collections/:collectionId/attributes')
}
foreach ($attributes as $attribute) {
if ($attribute->getAttribute('type') === Database::VAR_STRING) {
$filters = $attribute->getAttribute('filters', []);
+14 -10
View File
@@ -78,16 +78,20 @@ Database::addFilter(
foreach ($attributes as $attribute) {
$attributeType = $attribute->getAttribute('type');
if ($attributeType === Database::VAR_RELATIONSHIP) {
$options = $attribute->getAttribute('options');
foreach ($options as $key => $value) {
$attribute->setAttribute($key, $value);
}
$attribute->removeAttribute('options');
}
if ($attributeType === Database::VAR_STRING) {
$filters = $attribute->getAttribute('filters', []);
$attribute->setAttribute('encrypt', in_array('encrypt', $filters));
switch ($attributeType) {
case Database::VAR_RELATIONSHIP:
$options = $attribute->getAttribute('options');
foreach ($options as $key => $value) {
$attribute->setAttribute($key, $value);
}
$attribute->removeAttribute('options');
break;
case Database::VAR_STRING:
$filters = $attribute->getAttribute('filters', []);
$attribute->setAttribute('encrypt', in_array('encrypt', $filters));
break;
}
}
@@ -756,19 +756,15 @@ class DatabasesCustomServerTest extends Scope
'x-appwrite-key' => $this->getProject()['apiKey']
]), []);
$attributes = $actors['body']['attributes'];
$firstNameAttribute = null;
$lastNameAttribute = null;
foreach ($attributes as $attribute) {
$this->assertArrayHasKey('encrypt', $attribute);
if ($attribute['key'] === 'firstName') {
$firstNameAttribute = $attribute['encrypt'];
$this->assertFalse($attribute['encrypt']);
}
if ($attribute['key'] === 'lastName') {
$lastNameAttribute = $attribute['encrypt'];
$this->assertTrue($attribute['encrypt']);
}
}
$this->assertTrue($lastNameAttribute);
$this->assertFalse($firstNameAttribute);
}