Conversation
📝 WalkthroughWalkthroughThis PR updates spatial test data across E2E tests for Legacy and TablesDB. It replaces several coordinate sets (notably longitudes like -118.2437 and values like [100, 100]) with new values (e.g., -80 and [80, 80]) and adjusts corresponding assertions. In TablesDB custom server tests, an invalid point bulk-create now expects HTTP 400 instead of 201. Some line-string tests add an extra point [1.1, 1.1] and update “contains” queries accordingly. No public interfaces or control flow are changed; modifications are confined to test inputs and expected outcomes. Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Suggested reviewers
Pre-merge checks (2 warnings, 1 inconclusive)❌ Failed checks (2 warnings, 1 inconclusive)
✨ Finishing touches
🧪 Generate unit tests
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
|
There was a problem hiding this comment.
Actionable comments posted: 2
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php (1)
6676-6687: LGTM: LineString change fixes latitude bounds — but other out-of-range coordinates remainChanged [100,100] → [80,80] prevents validation failure in this test, but I found other hard-coded coordinate arrays that exceed ±90; fix these test literals:
- tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php:6409 — 'location' => [1000.0, 2000.0]
- tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php:6369 — 'location' => [1000.0, 2000.0]
🧹 Nitpick comments (8)
composer.json (2)
55-55: Call out behavior changes as breaking (spatial filters, 4xx codes).Per the related test updates, this DB bump changes spatial semantics (e.g., removed “contains on line” test) and error handling (e.g., invalid point → 400). Treat this as a breaking change: add migration notes, update API docs, and highlight in the PR description and release notes to avoid downstream surprises.
Would you like me to draft a short migration section summarizing the spatial changes and expected HTTP responses?
55-55: composer.lock pins the dev alias — add prefer-stable if this is temporary
- composer.lock pins utopia-php/database to dev-spatial-filter (ref 753800f9eb16bfd62b9647a0c54f39675dde728b); ensure composer.lock is committed in this PR.
- composer.json still contains the dev alias at line 55 and has no minimum-stability/prefer-stable set — add "config": { "prefer-stable": true } if you intend to keep dev constraints temporarily.
tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php (2)
6360-6383: Fix stale comment to match the new 400 expectationThe assertion now correctly expects 400 for invalid point coordinates, but the preceding comment still claims the create should succeed.
Apply:
- // Coordinates are not validated strictly; creation should succeed + // Invalid coordinates must be rejected; creation should fail
6649-6669: Avoid duplication: factor the updated LineString into a single variable used in both payload and assertionThe new endpoint [80, 80] looks good. Minor cleanup to keep the payload and expectation in sync.
- 'data' => [ - 'name' => 'Updated Path', - 'path' => [ - [0, 0], - [50, 50], - [80, 80] - ] // New LINE STRING - ], + // Keep request and assertion in sync + $newPath = [[0, 0], [50, 50], [80, 80]]; + 'data' => [ + 'name' => 'Updated Path', + 'path' => $newPath, // New LINE STRING + ],- $this->assertEquals([ - [0, 0], - [50, 50], - [80, 80] - ], $row['path']); + $this->assertEquals($newPath, $row['path']);tests/e2e/Services/Databases/Legacy/DatabasesBase.php (3)
5984-5990: Comment labels don’t match updated coordinatesThese values aren’t Los Angeles; keep the comment generic to avoid confusion.
- 'location' => [34.0522, -80] // Los Angeles coordinates + 'location' => [34.0522, -80] // example coordinates (lat, lon)
6116-6125: “LA route” label is misleading after longitude changeCoordinates no longer reflect LA; update the comment to a neutral label.
- 'route' => [[34.0522, -80], [34.0736, -90]] // LA route + 'route' => [[34.0522, -80], [34.0736, -90]] // example route (lat, lon)
6253-6262: Polygon comment still says “LA area”Use a neutral description so test data and commentary align.
- 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -90], [34.0522, -90], [34.0522, -80]]] // LA area + 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -90], [34.0522, -90], [34.0522, -80]]] // example area polygon (lat, lon)tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php (1)
6693-6701: Optional: refetch one updated doc to assert persistence, not just response echoAfter asserting the response payload, fetch one document by $id and assert the stored path equals [[0,0],[50,50],[80,80]] to guard against transient serialization or projection differences.
$this->assertEquals(200, $response['headers']['status-code']); $this->assertCount(3, $response['body']['documents']); // Verify updated documents foreach ($response['body']['documents'] as $document) { $this->assertEquals('Updated Path', $document['name']); $this->assertEquals([ [0, 0], [50, 50], - [80, 80] + [80, 80] ], $document['path']); } + + // Extra: verify persisted geometry by refetching the first doc + $firstId = $response['body']['documents'][0]['$id']; + $refetched = $this->client->call( + Client::METHOD_GET, + "/databases/{$databaseId}/collections/{$collectionId}/documents/{$firstId}", + array_merge(['content-type' => 'application/json','x-appwrite-project' => $this->getProject()['$id']], $this->getHeaders()) + ); + $this->assertEquals(200, $refetched['headers']['status-code']); + $this->assertEquals([[0,0],[50,50],[80,80]], $refetched['body']['path']);
📜 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 (5)
composer.json(1 hunks)tests/e2e/Services/Databases/Legacy/DatabasesBase.php(3 hunks)tests/e2e/Services/Databases/Legacy/DatabasesCustomServerTest.php(2 hunks)tests/e2e/Services/Databases/TablesDB/DatabasesBase.php(3 hunks)tests/e2e/Services/Databases/TablesDB/DatabasesCustomServerTest.php(3 hunks)
⏰ 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). (14)
- GitHub Check: E2E Service Test (Users)
- GitHub Check: E2E Service Test (Projects)
- GitHub Check: E2E Service Test (Realtime)
- GitHub Check: E2E Service Test (GraphQL)
- GitHub Check: E2E Service Test (FunctionsSchedule)
- GitHub Check: E2E Service Test (Functions)
- GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V2)
- GitHub Check: E2E Service Test (Avatars)
- GitHub Check: E2E Shared Mode Service Test (Site Screenshots) (Shared V1)
- GitHub Check: E2E Service Test (Dev Keys)
- GitHub Check: E2E Shared Mode Service Test (Dev Keys) (Shared V1)
- GitHub Check: Unit Test
- GitHub Check: E2E General Test
- GitHub Check: Benchmark
🔇 Additional comments (2)
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (2)
7618-7624: LGTM: point upsert coordinates and assertion updated consistentlyThe new point [34.0522, -80] matches the assertion; ordering remains consistent with the rest of the suite.
7752-7757: LGTM: line-string upsert updated and assertion alignedRoute now uses two points with longitude -80; assertion mirrors the change.
composer.json
Outdated
| "utopia-php/cli": "0.15.*", | ||
| "utopia-php/config": "0.2.*", | ||
| "utopia-php/database": "1.*", | ||
| "utopia-php/database": "dev-spatial-filter as 1.4.9", |
There was a problem hiding this comment.
🛠️ Refactor suggestion
Don’t alias a dev branch as a stable release; pin a commit instead.
dev-spatial-filter as 1.4.9 hides pre-release code behind a stable-looking version and risks accidental upgrades when the lockfile is regenerated. Pin the branch to a specific commit to keep builds deterministic, and plan to replace with an official tag ASAP.
Apply this change (replace with the intended SHA):
- "utopia-php/database": "dev-spatial-filter as 1.4.9",
+ "utopia-php/database": "dev-spatial-filter#<commit> as 1.4.9",📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| "utopia-php/database": "dev-spatial-filter as 1.4.9", | |
| "utopia-php/database": "dev-spatial-filter#<commit> as 1.4.9", |
🤖 Prompt for AI Agents
In composer.json at line 55, replace the aliased branch spec
"utopia-php/database": "dev-spatial-filter as 1.4.9" with a pinned-commit spec
using the intended SHA, e.g. "utopia-php/database": "dev-spatial-filter#<commit>
as 1.4.9" (substituting <commit> with the actual commit SHA), then
regenerate/update the lockfile (run composer update for that package) so
installs are deterministic; plan to switch to an official tag when available.
| 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]] | ||
| ] | ||
| ]); | ||
|
|
||
| $this->assertEquals(200, $response['headers']['status-code']); | ||
| $this->assertEquals([[[34.0522, -118.2437], [34.0736, -118.2437], [34.0736, -118.2400], [34.0522, -118.2400], [34.0522, -118.2437]]], $response['body']['area']); | ||
| $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]], $response['body']['area']); | ||
|
|
There was a problem hiding this comment.
Fix degenerate polygon (duplicate/collinear vertices produce zero area)
The new polygon repeats vertices and collapses to a line segment, which can be invalid in some spatial backends and undermine test intent. Suggest using a minimal rectangle to preserve a valid area.
Apply this diff:
- 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]]
+ 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -79.95], [34.0522, -79.95], [34.0522, -80]]]And update the assertion accordingly:
- $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]], $response['body']['area']);
+ $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -79.95], [34.0522, -79.95], [34.0522, -80]]], $response['body']['area']);📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]] | |
| ] | |
| ]); | |
| $this->assertEquals(200, $response['headers']['status-code']); | |
| $this->assertEquals([[[34.0522, -118.2437], [34.0736, -118.2437], [34.0736, -118.2400], [34.0522, -118.2400], [34.0522, -118.2437]]], $response['body']['area']); | |
| $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]], $response['body']['area']); | |
| 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -79.95], [34.0522, -79.95], [34.0522, -80]]] | |
| ] | |
| ]); | |
| $this->assertEquals(200, $response['headers']['status-code']); | |
| $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -79.95], [34.0522, -79.95], [34.0522, -80]]], $response['body']['area']); |
🤖 Prompt for AI Agents
In tests/e2e/Services/Databases/TablesDB/DatabasesBase.php around lines 7886 to
7892, the polygon supplied is degenerate (duplicate/collinear vertices collapse
to zero area); replace the repeated points with a minimal valid rectangle (four
distinct corner coords plus closing point) so the spatial backend sees a real
area, and update the following assertion to expect that same rectangle array in
$response['body']['area'] instead of the degenerate point list.
There was a problem hiding this comment.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
tests/e2e/Services/Databases/Legacy/DatabasesBase.php (1)
4179-4186: Fix fatal typo:CLient::METHOD_PUT→Client::METHOD_PUT.This will throw an undefined class/constant error at runtime.
- $collection = $this->client->call(CLient::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $collectionId, [ + $collection = $this->client->call(Client::METHOD_PUT, '/databases/' . $databaseId . '/collections/' . $collectionId, [
♻️ Duplicate comments (1)
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (1)
7883-7892: Fix degenerate polygon in upsert (zero-area ring due to duplicate/collinear points)The ring repeats vertices and collapses to a line segment; many spatial backends reject/fuzz this and it undermines test intent. Use a minimal rectangle (distinct corners + closing point).
Apply this patch:
- 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]] + 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -79.95], [34.0522, -79.95], [34.0522, -80]]]And update the assertion:
- $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -80], [34.0522, -80], [34.0522, -80]]], $response['body']['area']); + $this->assertEquals([[[34.0522, -80], [34.0736, -80], [34.0736, -79.95], [34.0522, -79.95], [34.0522, -80]]], $response['body']['area']);
🧹 Nitpick comments (4)
tests/e2e/Services/Databases/Legacy/DatabasesBase.php (3)
6119-6124: Rename “LA route” comment to match new coordinates.Coordinates
[[34.0522, -80], [34.0736, -90]]aren’t an LA route; adjust comment only.- 'route' => [[34.0522, -80], [34.0736, -90]] // LA route + 'route' => [[34.0522, -80], [34.0736, -90]] // Example route (lat ≈ 34, lon -80 → -90)
6256-6261: Rename “LA area” comment to reflect new polygon.The polygon longitudes
-80/-90aren’t LA; adjust comment to generic wording.- 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -90], [34.0522, -90], [34.0522, -80]]] // LA area + 'area' => [[[34.0522, -80], [34.0736, -80], [34.0736, -90], [34.0522, -90], [34.0522, -80]]] // Example area polygon (-80/-90 longitudes)
5984-5990: Update misleading comment(s): coordinates labeled "Los Angeles" are incorrect34.0522 is LA latitude but longitudes -80 and -90 are not (LA lon ≈ -118.2437). Either correct the longitudes or change the comments to something like "Example coordinates / route / area". Occurrences: tests/e2e/Services/Databases/Legacy/DatabasesBase.php:5984, 6119, 6256.
- 'location' => [34.0522, -80] // Los Angeles coordinates + 'location' => [34.0522, -80] // Example coordinates (lat ≈ 34.0522, lon -80)tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (1)
8160-8163: Nit: normalize spacing for readability; test semantics already correctKeep coordinate formatting consistent with surrounding code.
- 'lineAttr' => [[1.0, 1.0], [1.1,1.1] , [2.0, 2.0]], + 'lineAttr' => [[1.0, 1.0], [1.1, 1.1], [2.0, 2.0]],Also applies to: 8233-8237
📜 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 (2)
tests/e2e/Services/Databases/Legacy/DatabasesBase.php(5 hunks)tests/e2e/Services/Databases/TablesDB/DatabasesBase.php(4 hunks)
⏰ 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). (3)
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: Setup & Build Appwrite Image
- GitHub Check: scan
🔇 Additional comments (5)
tests/e2e/Services/Databases/Legacy/DatabasesBase.php (3)
6693-6699: LGTM: extra vertex ensures deterministic contains-on-line test.Adding
[1.1, 1.1]makes the subsequent contains query unambiguous.
6770-6776: LGTM: contains query aligned with updated geometry.
Query::contains('lineAttr', [[1.1, 1.1]])now correctly targets the new vertex.
6778-6778: No-op formatting change.Safe to keep or drop; no behavior impact.
tests/e2e/Services/Databases/TablesDB/DatabasesBase.php (2)
7615-7624: LGTM: point upsert coordinates and assertion are consistentUpsert uses [34.0522, -80] and the assertion matches. No further action.
7749-7758: LGTM: line route update and assertion matchRoute moved to [[34.0522, -80], [34.0736, -80]] with aligned expectation.
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