mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge pull request #12728 from appwrite/codex/fix-staged-transaction-timestamps
Fix staged transaction write timestamps
This commit is contained in:
3 files changed
+21
No files matched your search
@@ -85,6 +85,8 @@ class Document extends Any
|
||||
|
||||
if (!$document->isEmpty()) {
|
||||
$document->setAttribute('$sequence', (string)$document->getAttribute('$sequence', ''));
|
||||
$document->setAttribute('$createdAt', (string)$document->getAttribute('$createdAt', ''));
|
||||
$document->setAttribute('$updatedAt', (string)$document->getAttribute('$updatedAt', ''));
|
||||
}
|
||||
|
||||
foreach ($document->getAttributes() as $attribute) {
|
||||
|
||||
@@ -85,6 +85,8 @@ class Row extends Any
|
||||
|
||||
if (!$document->isEmpty()) {
|
||||
$document->setAttribute('$sequence', (string)$document->getAttribute('$sequence', ''));
|
||||
$document->setAttribute('$createdAt', (string)$document->getAttribute('$createdAt', ''));
|
||||
$document->setAttribute('$updatedAt', (string)$document->getAttribute('$updatedAt', ''));
|
||||
}
|
||||
|
||||
foreach ($document->getAttributes() as $column) {
|
||||
|
||||
@@ -100,6 +100,22 @@ trait TransactionsBase
|
||||
parent::tearDownAfterClass();
|
||||
}
|
||||
|
||||
protected function assertStagedWriteResponseSystemAttributes(array $body, bool $empty = false): void
|
||||
{
|
||||
$this->assertArrayHasKey('$sequence', $body, 'Staged write response should include $sequence for SDK model hydration.');
|
||||
$this->assertArrayHasKey('$createdAt', $body, 'Staged write response should include $createdAt for SDK model hydration.');
|
||||
$this->assertArrayHasKey('$updatedAt', $body, 'Staged write response should include $updatedAt for SDK model hydration.');
|
||||
$this->assertIsString($body['$sequence']);
|
||||
$this->assertIsString($body['$createdAt']);
|
||||
$this->assertIsString($body['$updatedAt']);
|
||||
|
||||
if ($empty) {
|
||||
$this->assertSame('', $body['$sequence']);
|
||||
$this->assertSame('', $body['$createdAt']);
|
||||
$this->assertSame('', $body['$updatedAt']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating a transaction
|
||||
*/
|
||||
@@ -1661,6 +1677,7 @@ trait TransactionsBase
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertStagedWriteResponseSystemAttributes($response['body'], empty: true);
|
||||
|
||||
// Document should not exist outside transaction yet
|
||||
$response = $this->client->call(Client::METHOD_GET, $this->getRecordUrl($databaseId, $collectionId, "doc_from_route"), array_merge([
|
||||
|
||||
Reference in new issue
Block a user