Skip to content

Bump database#10480

Merged
abnegate merged 4 commits into1.8.xfrom
spatial-type-attributes
Sep 12, 2025
Merged

Bump database#10480
abnegate merged 4 commits into1.8.xfrom
spatial-type-attributes

Conversation

@ArnabChatterjee20k
Copy link
Copy Markdown
Member

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

  • (Related PR or issue)

Checklist

  • Have you read the Contributing Guidelines on issues?
  • If the PR includes a change to an API's metadata (desc, label, params, etc.), does it also include updated API specs and example docs?

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Sep 11, 2025

📝 Walkthrough

Walkthrough

This 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

  • Fix mysql tests #10445 — Also updates spatial tests, including changing “contains” test coordinates to [1.1, 1.1], overlapping with the adjustments in this PR.

Suggested reviewers

  • abnegate
  • Meldiron

Pre-merge checks (2 warnings, 1 inconclusive)

❌ Failed checks (2 warnings, 1 inconclusive)
Check name Status Explanation Resolution
Title Check ⚠️ Warning The PR title "Bump database" is vague and does not describe the actual changes in the diff; the changeset updates spatial test data across multiple test files (coordinate changes and adjusted validation expectations such as an invalid point now returning 400), so the title is misleading for reviewers scanning history. Rename the PR to a concise title that highlights the primary change, for example "Update spatial test coordinates and validation expectations", and add a one-line summary in the PR body explaining why the coordinates/validation changed (e.g., database version bump or stricter spatial validation). This will make the change clearer to reviewers and maintainers.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description Check ❓ Inconclusive The PR description contains only the repository contribution template with placeholder sections and no concrete details about the changes; it does not summarize the updated spatial test data or the change in validation behavior seen in the diff, so the description is too vague for meaningful review. Populate the PR description with a brief summary of what changed (which tests/files and the nature of the changes), why the changes were necessary (e.g., database bump or stricter spatial validation), and a short test plan or verification steps including expected outcomes (noting cases now returning 400). Also reference any related issues or PRs to help reviewers assess intent and impact.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch spatial-type-attributes

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 11, 2025

Security Scan Results for PR

Docker Image Scan Results

Package Version Vulnerability Severity
golang.org/x/crypto v0.31.0 CVE-2025-22869 HIGH
golang.org/x/oauth2 v0.24.0 CVE-2025-22868 HIGH
stdlib 1.22.10 CVE-2025-47907 HIGH

Source Code Scan Results

🎉 No vulnerabilities found!

@github-actions
Copy link
Copy Markdown

github-actions bot commented Sep 11, 2025

✨ Benchmark results

  • Requests per second: 1,224
  • Requests with 200 status code: 220,454
  • P99 latency: 0.157598209

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,224 1,031
200 220,454 185,560
P99 0.157598209 0.188299214

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 remain

Changed [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 expectation

The 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 assertion

The 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 coordinates

These 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 change

Coordinates 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 echo

After 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

📥 Commits

Reviewing files that changed from the base of the PR and between 93fc3e7 and 738a42d.

⛔ Files ignored due to path filters (1)
  • composer.lock is 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 consistently

The 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 aligned

Route 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",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ 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.

Suggested change
"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.

Comment on lines +7886 to 7892
'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']);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

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.

Suggested change
'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.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_PUTClient::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/-90 aren’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 incorrect

34.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 correct

Keep 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

📥 Commits

Reviewing files that changed from the base of the PR and between 738a42d and addd140.

⛔ Files ignored due to path filters (1)
  • composer.lock is 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 consistent

Upsert uses [34.0522, -80] and the assertion matches. No further action.


7749-7758: LGTM: line route update and assertion match

Route moved to [[34.0522, -80], [34.0736, -80]] with aligned expectation.

@abnegate abnegate merged commit 918912c into 1.8.x Sep 12, 2025
86 checks passed
@abnegate abnegate deleted the spatial-type-attributes branch September 12, 2025 07:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants