-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add operator support #10735
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add operator support #10735
Conversation
📝 WalkthroughWalkthroughThis pull request adds new VCS repository sources to composer.json, updates email template styling to use a dynamic accent color variable, introduces a new email template for export failure notifications, and bumps versions for 16+ SDK packages across client, console, and server configurations. Changes are configuration and template updates with no modifications to core logic. Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes
Possibly related PRs
Suggested reviewers
Pre-merge checks and finishing touches❌ Failed checks (1 warning, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (286)
📒 Files selected for processing (3)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
🔇 Additional comments (3)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Security Scan Results for PRDocker Image Scan Results
Source Code Scan Results🎉 No vulnerabilities found! |
✨ Benchmark results
⚡ Benchmark Comparison
|
f8afe69 to
600da2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🧹 Nitpick comments (3)
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (3)
3113-3115: Reduce flakiness: replace fixed sleeps with readiness polling.
Polling table columns until status=available (or a short timeout) is more robust than sleep(2). Suggest a small helper that GETs columns and exits when all expected keys report status=available.
3142-3258: Add negative-path coverage for operator misuse.
Great success-path checks. Add a few failure cases to lock contract: increment on string, arrayAppend on non-array, and stringConcat on integer should 400.Apply this minimal diff after the stringConcat assertion:
@@ $this->assertEquals('Original Appended', $updated['body']['tagline']); + // Negative: numeric op on string should fail + $bad = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'title' => Operator::increment(1)->toString(), + ], + ]); + $this->assertEquals(400, $bad['headers']['status-code']); + + // Negative: array op on non-array should fail + $bad = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'title' => Operator::arrayAppend(['x'])->toString(), + ], + ]); + $this->assertEquals(400, $bad['headers']['status-code']); + + // Negative: string op on integer should fail + $bad = $this->client->call(Client::METHOD_PATCH, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $rowId, array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'data' => [ + 'releaseYear' => Operator::stringConcat('x')->toString(), + ], + ]); + $this->assertEquals(400, $bad['headers']['status-code']);
3335-3407: Tighten bulk assertions and add a control row.
- Use exact count (2) to keep the test deterministic.
- Create a non-matching row and verify it’s not updated.
Apply this diff:
@@ - $this->assertEquals(201, $row1['headers']['status-code']); - $this->assertEquals(201, $row2['headers']['status-code']); + $this->assertEquals(201, $row1['headers']['status-code']); + $this->assertEquals(201, $row2['headers']['status-code']); + + // Control row that must not be touched by bulk update + $control = $this->client->call(Client::METHOD_POST, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows', array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders()), [ + 'rowId' => ID::unique(), + 'data' => [ + 'title' => 'Unrelated', + 'releaseYear' => 1999, + 'actors' => [], + 'birthDay' => '2020-01-01 12:00:00', + ], + 'permissions' => [ + Permission::read(Role::users()), + Permission::update(Role::users()), + Permission::delete(Role::users()), + ], + ]); + $this->assertEquals(201, $control['headers']['status-code']); @@ - $this->assertEquals(200, $bulkUpdate['headers']['status-code']); - $this->assertGreaterThanOrEqual(2, $bulkUpdate['body']['total']); + $this->assertEquals(200, $bulkUpdate['headers']['status-code']); + $this->assertEquals(2, $bulkUpdate['body']['total']); @@ $this->assertEquals(200, $verify2['headers']['status-code']); $this->assertEquals(2031, $verify2['body']['releaseYear']); + + // Verify control row unchanged + $verify3 = $this->client->call(Client::METHOD_GET, '/tablesdb/' . $databaseId . '/tables/' . $tableId . '/rows/' . $control['body']['$id'], array_merge([ + 'content-type' => 'application/json', + 'x-appwrite-project' => $this->getProject()['$id'], + ], $this->getHeaders())); + $this->assertEquals(200, $verify3['headers']['status-code']); + $this->assertEquals(1999, $verify3['body']['releaseYear']);
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
composer.lockis excluded by!**/*.lock
📒 Files selected for processing (8)
composer.json(1 hunks)src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php(2 hunks)src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php(1 hunks)src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php(1 hunks)src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php(1 hunks)src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php(1 hunks)tests/e2e/Services/Databases/Legacy/DatabasesBase.php(2 hunks)tests/e2e/Services/Databases/TablesDB/DatabasesBase.php(2 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
- src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Upsert.php
- src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Update.php
- composer.json
- src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Bulk/Update.php
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-05-10T04:12:13.037Z
Learnt from: ItzNotABug
Repo: appwrite/appwrite PR: 9693
File: src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Indexes/Delete.php:85-86
Timestamp: 2025-05-10T04:12:13.037Z
Learning: The class `Appwrite\Platform\Modules\Databases\Http\Databases\Collections\Indexes\Action` defines a method `getGrantParentNotFoundException()` which is used to handle cases where a parent resource (like a database collection) is not found.
Applied to files:
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php
📚 Learning: 2025-06-19T09:20:03.312Z
Learnt from: ItzNotABug
Repo: appwrite/appwrite PR: 9693
File: src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Update.php:57-59
Timestamp: 2025-06-19T09:20:03.312Z
Learning: In table-related endpoints (such as `src/Appwrite/Platform/Modules/Databases/Http/Databases/Tables/Update.php`), parameter descriptions should use "table" and "row" terminology instead of "collection" and "document" for clarity and consistency.
Applied to files:
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php
🧬 Code graph analysis (4)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php (1)
src/Appwrite/Extend/Exception.php (1)
Exception(7-464)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php (1)
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php (1)
parseOperators(350-387)
tests/e2e/Services/Databases/Legacy/DatabasesBase.php (3)
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (2)
testOperators(3012-3258)testBulkOperators(3260-3408)tests/e2e/Client.php (1)
Client(8-342)tests/e2e/Scopes/Scope.php (1)
getHeaders(145-145)
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (2)
tests/e2e/Services/Databases/Legacy/DatabasesBase.php (2)
testOperators(3106-3352)testBulkOperators(3354-3502)tests/e2e/Client.php (1)
Client(8-342)
🔇 Additional comments (6)
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (1)
13-13: LGTM: Operator import is correct and required for tests.tests/e2e/Services/Databases/Legacy/DatabasesBase.php (2)
3106-3352: Thorough single-document operator coverage. These assertions exercise every new operator path—numeric delta, array prepend/append, string concat, and upsert reuse—so we’ll quickly catch regressions in parseOperators across legacy documents.
3354-3502: Nice bulk-operator validation. Verifying the patch-and-query flow plus the follow-up reads ensures bulk updates honor operator semantics as well as query scoping, which is exactly what the new parser needs.src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Upsert.php (1)
121-122: LGTM!The placement of
parseOperatorsis correct—it transforms operator JSON strings after collection validation but before permission aggregation and the upsert flow. This aligns with the preprocessing pattern applied in other document-handling endpoints.src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php (2)
10-10: LGTM!The import is necessary for the
parseOperatorsmethod implementation.
342-350: LGTM!The method signature and documentation are clear and appropriate. The return type correctly reflects that the array contains mixed value types after operator parsing.
src/Appwrite/Platform/Modules/Databases/Http/Databases/Collections/Documents/Action.php
Show resolved
Hide resolved
# Conflicts: # composer.lock
commit: |
What does this PR do?
(Provide a description of what this PR does and why it's needed.)
Test Plan
(Write your test plan here. If you changed any code, please provide us with clear instructions on how you verified your changes work. Screenshots may also be helpful.)
Related PRs and Issues
Checklist