mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Merge pull request #3307 from appwrite/fix-subquery-limit
fix: increase subquery limit
This commit is contained in:
commit
43a5d419e8
1 changed files with 43 additions and 38 deletions
81
app/init.php
81
app/init.php
|
|
@ -78,6 +78,7 @@ const APP_LIMIT_ANTIVIRUS = 20000000; //20MB
|
||||||
const APP_LIMIT_ENCRYPTION = 20000000; //20MB
|
const APP_LIMIT_ENCRYPTION = 20000000; //20MB
|
||||||
const APP_LIMIT_COMPRESSION = 20000000; //20MB
|
const APP_LIMIT_COMPRESSION = 20000000; //20MB
|
||||||
const APP_LIMIT_ARRAY_PARAMS_SIZE = 100; // Default maximum of how many elements can there be in API parameter that expects array value
|
const APP_LIMIT_ARRAY_PARAMS_SIZE = 100; // Default maximum of how many elements can there be in API parameter that expects array value
|
||||||
|
const APP_LIMIT_SUBQUERY = 1000;
|
||||||
const APP_CACHE_BUSTER = 305;
|
const APP_CACHE_BUSTER = 305;
|
||||||
const APP_VERSION_STABLE = '0.14.2';
|
const APP_VERSION_STABLE = '0.14.2';
|
||||||
const APP_DATABASE_ATTRIBUTE_EMAIL = 'email';
|
const APP_DATABASE_ATTRIBUTE_EMAIL = 'email';
|
||||||
|
|
@ -191,46 +192,50 @@ if (!empty($user) || !empty($pass)) {
|
||||||
*/
|
*/
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'casting',
|
'casting',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return json_encode(['value' => $value], JSON_PRESERVE_ZERO_FRACTION);
|
return json_encode(['value' => $value], JSON_PRESERVE_ZERO_FRACTION);
|
||||||
},
|
},
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return json_decode($value, true)['value'];
|
return json_decode($value, true)['value'];
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'enum',
|
'enum',
|
||||||
function ($value, Document $attribute) {
|
function (mixed $value, Document $attribute) {
|
||||||
if ($attribute->isSet('elements')) {
|
if ($attribute->isSet('elements')) {
|
||||||
$attribute->removeAttribute('elements');
|
$attribute->removeAttribute('elements');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
function ($value, Document $attribute) {
|
function (mixed $value, Document $attribute) {
|
||||||
$formatOptions = json_decode($attribute->getAttribute('formatOptions', '[]'), true);
|
$formatOptions = json_decode($attribute->getAttribute('formatOptions', '[]'), true);
|
||||||
if (isset($formatOptions['elements'])) {
|
if (isset($formatOptions['elements'])) {
|
||||||
$attribute->setAttribute('elements', $formatOptions['elements']);
|
$attribute->setAttribute('elements', $formatOptions['elements']);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'range',
|
'range',
|
||||||
function ($value, Document $attribute) {
|
function (mixed $value, Document $attribute) {
|
||||||
if ($attribute->isSet('min')) {
|
if ($attribute->isSet('min')) {
|
||||||
$attribute->removeAttribute('min');
|
$attribute->removeAttribute('min');
|
||||||
}
|
}
|
||||||
if ($attribute->isSet('max')) {
|
if ($attribute->isSet('max')) {
|
||||||
$attribute->removeAttribute('max');
|
$attribute->removeAttribute('max');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
},
|
},
|
||||||
function ($value, Document $attribute) {
|
function (mixed $value, Document $attribute) {
|
||||||
$formatOptions = json_decode($attribute->getAttribute('formatOptions', '[]'), true);
|
$formatOptions = json_decode($attribute->getAttribute('formatOptions', '[]'), true);
|
||||||
if (isset($formatOptions['min']) || isset($formatOptions['max'])) {
|
if (isset($formatOptions['min']) || isset($formatOptions['max'])) {
|
||||||
$attribute
|
$attribute
|
||||||
|
|
@ -238,134 +243,134 @@ Database::addFilter(
|
||||||
->setAttribute('max', $formatOptions['max'])
|
->setAttribute('max', $formatOptions['max'])
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryAttributes',
|
'subQueryAttributes',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return $database
|
return $database
|
||||||
->find('attributes', [
|
->find('attributes', [
|
||||||
new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getAttributeLimit(), 0, []);
|
], $database->getAttributeLimit());
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryIndexes',
|
'subQueryIndexes',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return $database
|
return $database
|
||||||
->find('indexes', [
|
->find('indexes', [
|
||||||
new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('collectionId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], 64, 0, []);
|
], 64);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryPlatforms',
|
'subQueryPlatforms',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return $database
|
return $database
|
||||||
->find('platforms', [
|
->find('platforms', [
|
||||||
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []);
|
], APP_LIMIT_SUBQUERY);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryDomains',
|
'subQueryDomains',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return $database
|
return $database
|
||||||
->find('domains', [
|
->find('domains', [
|
||||||
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []);
|
], APP_LIMIT_SUBQUERY);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryKeys',
|
'subQueryKeys',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return $database
|
return $database
|
||||||
->find('keys', [
|
->find('keys', [
|
||||||
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []);
|
], APP_LIMIT_SUBQUERY);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryWebhooks',
|
'subQueryWebhooks',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return $database
|
return $database
|
||||||
->find('webhooks', [
|
->find('webhooks', [
|
||||||
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('projectId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []);
|
], APP_LIMIT_SUBQUERY);
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQuerySessions',
|
'subQuerySessions',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
$sessions = Authorization::skip(fn () => $database->find('sessions', [
|
return Authorization::skip(fn () => $database->find('sessions', [
|
||||||
new Query('userId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('userId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []));
|
], APP_LIMIT_SUBQUERY));
|
||||||
|
|
||||||
return $sessions;
|
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryTokens',
|
'subQueryTokens',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return Authorization::skip(fn() => $database
|
return Authorization::skip(fn() => $database
|
||||||
->find('tokens', [
|
->find('tokens', [
|
||||||
new Query('userId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('userId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []));
|
], APP_LIMIT_SUBQUERY));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'subQueryMemberships',
|
'subQueryMemberships',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
return null;
|
return null;
|
||||||
},
|
},
|
||||||
function ($value, Document $document, Database $database) {
|
function (mixed $value, Document $document, Database $database) {
|
||||||
return Authorization::skip(fn() => $database
|
return Authorization::skip(fn() => $database
|
||||||
->find('memberships', [
|
->find('memberships', [
|
||||||
new Query('userId', Query::TYPE_EQUAL, [$document->getId()])
|
new Query('userId', Query::TYPE_EQUAL, [$document->getId()])
|
||||||
], $database->getIndexLimit(), 0, []));
|
], APP_LIMIT_SUBQUERY));
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
Database::addFilter(
|
Database::addFilter(
|
||||||
'encrypt',
|
'encrypt',
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
$key = App::getEnv('_APP_OPENSSL_KEY_V1');
|
$key = App::getEnv('_APP_OPENSSL_KEY_V1');
|
||||||
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
|
$iv = OpenSSL::randomPseudoBytes(OpenSSL::cipherIVLength(OpenSSL::CIPHER_AES_128_GCM));
|
||||||
$tag = null;
|
$tag = null;
|
||||||
|
|
||||||
return json_encode([
|
return json_encode([
|
||||||
'data' => OpenSSL::encrypt($value, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag),
|
'data' => OpenSSL::encrypt($value, OpenSSL::CIPHER_AES_128_GCM, $key, 0, $iv, $tag),
|
||||||
'method' => OpenSSL::CIPHER_AES_128_GCM,
|
'method' => OpenSSL::CIPHER_AES_128_GCM,
|
||||||
|
|
@ -374,7 +379,7 @@ Database::addFilter(
|
||||||
'version' => '1',
|
'version' => '1',
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
function ($value) {
|
function (mixed $value) {
|
||||||
if (is_null($value)) {
|
if (is_null($value)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue