Fix spatial index column issue
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.svelteto 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
createfunction 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.
Console (appwrite/console)
Project ID: 688b7bf400350cbd60e9
[!TIP] Global CDN and DDoS protection come free with every Sites deployment
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
columnListhandling when toggling to/from Spatial: preservation logic, reset path, andordernormalization. - Inspect
create()staged validations and the order of notification vs throw for different failure branches. - Confirm preserved spatial column has
orderset tonulland non‑spatial transition setsordertoASC. - 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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@copilot
@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.
