mirror of
https://github.com/appwrite/appwrite.git
synced 2026-05-26 13:51:13 +00:00
fix: return \$sequence as string and add V21 backward-compat filters
This commit is contained in:
@@ -843,8 +843,7 @@ class OpenAPI3 extends Format
|
||||
break;
|
||||
|
||||
case 'id':
|
||||
$type = 'integer';
|
||||
$format = $rule['format'] ?? 'int32';
|
||||
$type = 'string';
|
||||
break;
|
||||
|
||||
case 'enum':
|
||||
|
||||
@@ -823,8 +823,7 @@ class Swagger2 extends Format
|
||||
break;
|
||||
|
||||
case 'id':
|
||||
$type = 'integer';
|
||||
$format = $rule['format'] ?? 'int32';
|
||||
$type = 'string';
|
||||
break;
|
||||
|
||||
case 'enum':
|
||||
|
||||
@@ -23,6 +23,18 @@ class V21 extends Filter
|
||||
"functions",
|
||||
fn ($item) => $this->parseFunction($item),
|
||||
),
|
||||
Response::MODEL_DOCUMENT => $this->parseDocument($content),
|
||||
Response::MODEL_DOCUMENT_LIST => $this->handleList(
|
||||
$content,
|
||||
"documents",
|
||||
fn ($item) => $this->parseDocument($item),
|
||||
),
|
||||
Response::MODEL_ROW => $this->parseRow($content),
|
||||
Response::MODEL_ROW_LIST => $this->handleList(
|
||||
$content,
|
||||
"rows",
|
||||
fn ($item) => $this->parseRow($item),
|
||||
),
|
||||
default => $content,
|
||||
};
|
||||
}
|
||||
@@ -46,4 +58,24 @@ class V21 extends Filter
|
||||
unset($content['runtimeSpecification']);
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseDocument(array $content): array
|
||||
{
|
||||
if (isset($content['$sequence'])) {
|
||||
$content['$sequence'] = \is_numeric($content['$sequence'])
|
||||
? (int)$content['$sequence']
|
||||
: 0;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
|
||||
protected function parseRow(array $content): array
|
||||
{
|
||||
if (isset($content['$sequence'])) {
|
||||
$content['$sequence'] = \is_numeric($content['$sequence'])
|
||||
? (int)$content['$sequence']
|
||||
: 0;
|
||||
}
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,8 +83,8 @@ class Document extends Any
|
||||
$document->removeAttribute('$collection');
|
||||
$document->removeAttribute('$tenant');
|
||||
|
||||
if (!$document->isEmpty() && \is_numeric($document->getAttribute('$sequence', 0))) {
|
||||
$document->setAttribute('$sequence', (int)$document->getAttribute('$sequence', 0));
|
||||
if (!$document->isEmpty()) {
|
||||
$document->setAttribute('$sequence', (string)$document->getAttribute('$sequence', ''));
|
||||
}
|
||||
|
||||
foreach ($document->getAttributes() as $attribute) {
|
||||
|
||||
@@ -83,8 +83,8 @@ class Row extends Any
|
||||
$document->removeAttribute('$collection');
|
||||
$document->removeAttribute('$tenant');
|
||||
|
||||
if (!$document->isEmpty() && \is_numeric($document->getAttribute('$sequence', 0))) {
|
||||
$document->setAttribute('$sequence', (int)$document->getAttribute('$sequence', 0));
|
||||
if (!$document->isEmpty()) {
|
||||
$document->setAttribute('$sequence', (string)$document->getAttribute('$sequence', ''));
|
||||
}
|
||||
|
||||
foreach ($document->getAttributes() as $column) {
|
||||
|
||||
Reference in New Issue
Block a user