console icon indicating copy to clipboard operation
console copied to clipboard

Fix spatial index column issue

Open Divyansha23 opened this issue 3 months ago • 4 comments

What does this PR do?

This pull request improves the user experience and validation logic when creating indexes on database tables, especially handling spatial indexes more robustly. The changes ensure that incompatible columns are reset when switching index types and that users receive clear error notifications for invalid input.

Test Plan

  • Enhanced the logic in createIndex.svelte to reset the column list appropriately when switching to or from spatial index types, ensuring only compatible columns are selected and orders are set correctly. (src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/indexes/createIndex.svelteL71-R90)

Validation and error notification enhancements:

  • Updated the create function to add stricter validation for required fields and spatial column selection, providing clear error notifications if requirements are not met. (src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/indexes/createIndex.svelteL125-R158)UTING.md

Related PRs and Issues

(If this PR is related to any other PR or resolves any issue or related to any issue link all related PR and issues here.)

Have you read the Contributing Guidelines on issues?

(Write your answer here.)

Summary by CodeRabbit

  • Bug Fixes
    • Smarter column handling when switching index types — preserves a valid spatial column or resets to a single empty column and ensures ordering is set appropriately when switching away.
    • More explicit, staged validation during index creation with clearer error notifications for missing key, missing type, or missing required spatial column.
    • Minor column-filtering tweak while preserving add/remove behavior and navigation formatting.

✏️ Tip: You can customize this high-level summary in your review settings.

Divyansha23 avatar Nov 20 '25 08:11 Divyansha23

Console (appwrite/console)

Project ID: 688b7bf400350cbd60e9

Sites (1)
Site Status Logs Preview QR
 console-stage
688b7cf6003b1842c9dc
Ready Ready View Logs Preview URL QR Code

[!TIP] Global CDN and DDoS protection come free with every Sites deployment

appwrite[bot] avatar Nov 20 '25 08:11 appwrite[bot]

Walkthrough

Refines index-creation logic for Spatial vs non‑Spatial index types and makes validation steps explicit. When switching to Spatial, attempts to preserve a valid spatial column entry (setting its order to null) or resets to a single empty entry; when switching away, converts a null order to ASC for the first column. create() now performs staged validations: checks key and type, enforces a selected spatial column for Spatial indexes with error notification + throw, and preserves existing add/remove column behavior. Minor comment and path-string formatting tweaks present.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Verify columnList handling when toggling to/from Spatial: preservation logic, reset path, and order normalization.
  • Inspect create() staged validations and the order of notification vs throw for different failure branches.
  • Confirm preserved spatial column has order set to null and non‑spatial transition sets order to ASC.
  • Review minor comment and path-string changes for accidental regressions.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix spatial index column issue' directly addresses the main change: fixing spatial index column handling logic in the createIndex component.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • [ ] Create PR with unit tests
  • [ ] Post copyable unit tests in a comment
  • [ ] Commit unit tests in branch fix-spatial-index-column-issue

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.

coderabbitai[bot] avatar Nov 20 '25 08:11 coderabbitai[bot]

@copilot

Divyansha23 avatar Nov 20 '25 08:11 Divyansha23

@Divyansha23 I've opened a new pull request, #2622, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot avatar Nov 20 '25 08:11 Copilot