(fix): alias Query\Method as QueryMethod to avoid SDK\Method collision

This commit is contained in:
Jake Barnby
2026-03-27 02:37:41 +13:00
parent 3e2504e75a
commit efa7ccc8fc
7 changed files with 25 additions and 25 deletions
+2 -2
View File
@@ -31,7 +31,7 @@ use Utopia\Database\Validator\UID;
use Utopia\Emails\Validator\Email;
use Utopia\Http\Http;
use Utopia\Locale\Locale;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\System\System;
use Utopia\Validator\ArrayList;
use Utopia\Validator\Boolean;
@@ -873,7 +873,7 @@ Http::get('/v1/projects/:projectId/keys')
}
// Backwards compatibility
if (\count(Query::getByType($queries, [Method::Limit])) === 0) {
if (\count(Query::getByType($queries, [QueryMethod::Limit])) === 0) {
$queries[] = Query::limit(5000);
}
+10 -10
View File
@@ -56,7 +56,7 @@ use Utopia\Logger\Log;
use Utopia\Logger\Log\User;
use Utopia\Logger\Logger;
use Utopia\Platform\Service;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\Span\Span;
use Utopia\System\System;
use Utopia\Validator;
@@ -1343,7 +1343,7 @@ Http::error()
}
// logical queries - recursively format nested queries
if (in_array($method, [Method::And, Method::Or], true)) {
if (in_array($method, [QueryMethod::And, QueryMethod::Or], true)) {
$nested = [];
foreach ($values as $nestedArray) {
if (is_array($nestedArray)) {
@@ -1357,26 +1357,26 @@ Http::error()
}
// select - show selected attributes
if ($method === Method::Select) {
if ($method === QueryMethod::Select) {
$attributes = array_values(array_filter($values, 'is_string'));
return [$method => $attributes];
}
// pagination
if (in_array($method, [
Method::Limit,
Method::Offset,
Method::CursorAfter,
Method::CursorBefore
QueryMethod::Limit,
QueryMethod::Offset,
QueryMethod::CursorAfter,
QueryMethod::CursorBefore
], true)) {
return [$method => []];
}
// orders
if (in_array($method, [
Method::OrderDesc,
Method::OrderAsc,
Method::OrderRandom
QueryQueryMethod::OrderDesc,
QueryQueryMethod::OrderAsc,
QueryQueryMethod::OrderRandom
], true)) {
return [$method => !empty($attribute) ? [$attribute] : []];
}
@@ -18,7 +18,7 @@ use Utopia\Database\Validator\Authorization;
use Utopia\Database\Validator\Query\Cursor;
use Utopia\Database\Validator\UID;
use Utopia\Http\Adapter\Swoole\Response as SwooleResponse;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\Query\Schema\ColumnType;
use Utopia\Validator\Boolean;
@@ -96,7 +96,7 @@ class XList extends Action
$cursor = \array_filter(
$queries,
fn ($query) => \in_array($query->getMethod(), [Method::CursorAfter, Method::CursorBefore])
fn ($query) => \in_array($query->getMethod(), [QueryMethod::CursorAfter, QueryMethod::CursorBefore])
);
$cursor = \reset($cursor);
@@ -21,7 +21,7 @@ use Utopia\Database\Validator\Query\Cursor;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\Validator\Boolean;
class XList extends Base
@@ -120,7 +120,7 @@ class XList extends Base
// Capture what statuses the caller explicitly requested, before we mutate the query.
$requestedStatuses = [];
foreach ($queries as $query) {
if ($query->getMethod() === Method::Equal && $query->getAttribute() === 'status') {
if ($query->getMethod() === QueryMethod::Equal && $query->getAttribute() === 'status') {
$requestedStatuses = [...$requestedStatuses, ...$query->getValues()];
}
}
@@ -129,7 +129,7 @@ class XList extends Base
// waiting/processing executions created before the timeout threshold, so timed-out
// executions that were never marked failed in the DB are included in the results.
foreach ($queries as $index => $query) {
if ($query->getMethod() === Method::Equal && $query->getAttribute() === 'status' && \in_array('failed', $query->getValues())) {
if ($query->getMethod() === QueryMethod::Equal && $query->getAttribute() === 'status' && \in_array('failed', $query->getValues())) {
$queries[$index] = Query::or([
$query,
Query::and([
@@ -20,7 +20,7 @@ use Utopia\Database\Validator\Query\Cursor;
use Utopia\Database\Validator\UID;
use Utopia\Platform\Action;
use Utopia\Platform\Scope\HTTP;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\Validator\Boolean;
class XList extends Base
@@ -109,7 +109,7 @@ class XList extends Base
// Capture what statuses the caller explicitly requested, before we mutate the query.
$requestedStatuses = [];
foreach ($queries as $query) {
if ($query->getMethod() === Method::Equal && $query->getAttribute() === 'status') {
if ($query->getMethod() === QueryMethod::Equal && $query->getAttribute() === 'status') {
$requestedStatuses = [...$requestedStatuses, ...$query->getValues()];
}
}
@@ -118,7 +118,7 @@ class XList extends Base
// waiting/processing logs created before the timeout threshold, so timed-out
// logs that were never marked failed in the DB are included in the results.
foreach ($queries as $index => $query) {
if ($query->getMethod() === Method::Equal && $query->getAttribute() === 'status' && \in_array('failed', $query->getValues())) {
if ($query->getMethod() === QueryMethod::Equal && $query->getAttribute() === 'status' && \in_array('failed', $query->getValues())) {
$queries[$index] = Query::or([
$query,
Query::and([
@@ -51,7 +51,7 @@ use Utopia\Detector\Detector\Packager;
use Utopia\Detector\Detector\Runtime;
use Utopia\Detector\Detector\Strategy;
use Utopia\Platform\Scope\HTTP;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\System\System;
use Utopia\Validator\Text;
use Utopia\Validator\WhiteList;
@@ -130,8 +130,8 @@ class XList extends Action
$github->initializeVariables($providerInstallationId, $privateKey, $githubAppId);
$queries = Query::parseQueries($queries);
$limitQuery = current(array_filter($queries, fn ($query) => $query->getMethod() === Method::Limit));
$offsetQuery = current(array_filter($queries, fn ($query) => $query->getMethod() === Method::Offset));
$limitQuery = current(array_filter($queries, fn ($query) => $query->getMethod() === QueryMethod::Limit));
$offsetQuery = current(array_filter($queries, fn ($query) => $query->getMethod() === QueryMethod::Offset));
$limit = !empty($limitQuery) ? $limitQuery->getValue() : 4;
$offset = !empty($offsetQuery) ? $offsetQuery->getValue() : 0;
@@ -16,7 +16,7 @@ use Utopia\Database\Exception\Query as QueryException;
use Utopia\Database\Query;
use Utopia\Database\Validator\Query\Cursor;
use Utopia\Platform\Scope\HTTP;
use Utopia\Query\Method;
use Utopia\Query\Method as QueryMethod;
use Utopia\Validator\Boolean;
use Utopia\Validator\Text;
@@ -84,7 +84,7 @@ class XList extends Action
* Get cursor document if there was a cursor query, we use array_filter and reset for reference $cursor to $queries
*/
$cursor = \array_filter($queries, function ($query) {
return \in_array($query->getMethod(), [Method::CursorAfter, Method::CursorBefore]);
return \in_array($query->getMethod(), [QueryMethod::CursorAfter, QueryMethod::CursorBefore]);
});
$cursor = reset($cursor);
if ($cursor) {