- 
                Notifications
    You must be signed in to change notification settings 
- Fork 190
fix - added push command support for cli spatial types #1241
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
Conversation
| WalkthroughThis pull request adds support for three geospatial attribute types (point, linestring, polygon) to the CLI push command. Six new handler methods are added to the databases module and exposed through the import statement. The createAttribute and updateAttribute functions are extended with new cases that route these geospatial types to their respective create/update handlers, passing the appropriate parameters (databaseId, collectionId, key, required, xdefault, and parseOutput: false). Unsupported types continue to throw errors as before. Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 
 Key areas requiring attention: 
 Pre-merge checks and finishing touches❌ Failed checks (1 warning)
 ✅ Passed checks (2 passed)
 ✨ Finishing touches
 🧪 Generate unit tests (beta)
 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  | 
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 (2)
templates/cli/lib/commands/push.js.twig (2)
571-579: Spatial create: confirm array support; fix minor style
- Do spatial attributes support array? Other types pass array: attribute.array. If supported, add it here; if not, keep as-is. Please confirm against the API.
- Minor style: add spaces after colons to match surrounding code.
If arrays are supported for point/linestring/polygon, update payloads accordingly (and mirror in updateAttribute).
Style-only diff:
case 'point': return databasesCreatePointAttribute({ databaseId, collectionId, - key:attribute.key, - required:attribute.required, - xdefault:attribute.default, - parseOutput:false + key: attribute.key, + required: attribute.required, + xdefault: attribute.default, + parseOutput: false }) case 'linestring': return databasesCreateLineAttribute({ databaseId, collectionId, - key:attribute.key, - required:attribute.required, - xdefault:attribute.default, - parseOutput:false + key: attribute.key, + required: attribute.required, + xdefault: attribute.default, + parseOutput: false }) case 'polygon': return databasesCreatePolygonAttribute({ databaseId, collectionId, - key:attribute.key, - required:attribute.required, - xdefault:attribute.default, - parseOutput:false + key: attribute.key, + required: attribute.required, + xdefault: attribute.default, + parseOutput: false })Also applies to: 581-588, 590-597
717-725: Spatial update: mirror create decisions; fix minor style
- Mirror the createAttribute decision on array support (add array: attribute.array if the API supports it).
- Normalize spacing for consistency.
Confirm API support for arrays on spatial updates; adjust payloads if applicable.
Style-only diff:
case 'point': return databasesUpdatePointAttribute({ databaseId, collectionId, - key:attribute.key, - required:attribute.required, - xdefault:attribute.default, - parseOutput:false + key: attribute.key, + required: attribute.required, + xdefault: attribute.default, + parseOutput: false }) case 'linestring': return databasesUpdateLineAttribute({ databaseId, collectionId, - key:attribute.key, - required:attribute.required, - xdefault:attribute.default, - parseOutput:false + key: attribute.key, + required: attribute.required, + xdefault: attribute.default, + parseOutput: false }) case 'polygon': return databasesUpdatePolygonAttribute({ databaseId, collectionId, - key:attribute.key, - required:attribute.required, - xdefault:attribute.default, - parseOutput:false + key: attribute.key, + required: attribute.required, + xdefault: attribute.default, + parseOutput: false })Also applies to: 727-734, 736-743
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
- templates/cli/lib/commands/push.js.twig(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). (17)
- GitHub Check: build (8.3, Ruby27)
- GitHub Check: build (8.3, AppleSwift56)
- GitHub Check: build (8.3, Python39)
- GitHub Check: build (8.3, WebNode)
- GitHub Check: build (8.3, Ruby30)
- GitHub Check: build (8.3, Swift56)
- GitHub Check: build (8.3, KotlinJava8)
- GitHub Check: build (8.3, Node18)
- GitHub Check: build (8.3, Node16)
- GitHub Check: build (8.3, DotNet80)
- GitHub Check: build (8.3, DartStable)
- GitHub Check: build (8.3, CLINode16)
- GitHub Check: swift (server)
- GitHub Check: build (8.3, Android14Java17)
- GitHub Check: apple (client)
- GitHub Check: build (8.3, Android5Java17)
- GitHub Check: android (client)
| databasesCreatePointAttribute, | ||
| databasesUpdatePointAttribute, | ||
| databasesCreateLineAttribute, | ||
| databasesUpdateLineAttribute, | ||
| databasesCreatePolygonAttribute, | ||
| databasesUpdatePolygonAttribute, | 
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.
🧩 Analysis chain
Verify new databases exports exist and match names
Ensure these functions are actually defined and exported from ./databases with the exact identifiers used here (especially “Line” vs “linestring” naming).
Run:
🏁 Script executed:
#!/bin/bash
# Find definitions or exports of the new spatial helpers
rg -nC2 -S --glob '!**/node_modules/**' \
  -e '\b(databases(Create|Update)(Point|Line|Polygon)Attribute)\b' \
  -e 'module\.exports\s*=\s*{[^}]*databases(Create|Update)(Point|Line|Polygon)Attribute' Length of output: 306
I'll generate a simplified verification script to search for these functions without the complex regex pattern:
🏁 Script executed:
#!/bin/bash
# Step 1: Find the databases module file
echo "=== Finding databases module ==="
fd -t f 'databases\.(js|ts)' --glob '!**/node_modules/**' | head -20
echo ""
echo "=== Searching for spatial attribute functions ==="
# Search for each function name separately with simpler patterns
rg -n 'databasesCreatePointAttribute|databasesUpdatePointAttribute|databasesCreateLineAttribute|databasesUpdateLineAttribute|databasesCreatePolygonAttribute|databasesUpdatePolygonAttribute' --glob '!**/node_modules/**' -C1Length of output: 2250
🏁 Script executed:
#!/bin/bash
# Find the import statement to see where these come from
echo "=== Import statement context ==="
rg -n 'databasesCreatePointAttribute|from.*databases' templates/cli/lib/commands/push.js.twig -B5 | head -40
echo ""
echo "=== Looking for databases module in lib/sdks or similar ==="
fd -t f 'databases' --type file | grep -E '\.(js|ts)$' | grep -v node_modules | head -20
echo ""
echo "=== Check for databases exports/definitions ==="
rg -n 'export.*databasesCreatePointAttribute|databasesCreatePointAttribute\s*=|function databasesCreatePointAttribute' --glob '!**/node_modules/**' -A2Length of output: 622
🏁 Script executed:
#!/bin/bash
# Find the import statement to see where these come from
echo "=== Import statement context ==="
rg -n 'from.*databases|import.*databases' templates/cli/lib/commands/push.js.twig -B2 -A2 | head -50
echo ""
echo "=== Looking for databases module in sdks or sdk/functions ==="
fd 'databases' -type f | grep -E '\.(js|ts)$' | grep -v node_modules
echo ""
echo "=== Check for database spatial attribute function definitions ==="
rg -n 'databasesCreatePointAttribute|databasesCreateLineAttribute|databasesCreatePolygonAttribute' --glob '!**/node_modules/**' -A3Length of output: 1915
🏁 Script executed:
#!/bin/bash
# Look at the beginning of push.js.twig to find import statements
echo "=== First 60 lines of push.js.twig ==="
head -60 templates/cli/lib/commands/push.js.twig
echo ""
echo "=== Search for where databases imports come from ==="
rg -n '^\s*import|^\s*const.*=.*require|from\s' templates/cli/lib/commands/push.js.twig | head -20
echo ""
echo "=== Look for any files containing these function names as exports ==="
rg -n 'export.*Point|export.*Line|export.*Polygon' --glob '!**/node_modules/**'Length of output: 4870
🏁 Script executed:
#!/bin/bash
# Find databases.js in the commands directory
echo "=== Looking for databases file in commands directory ==="
ls -la templates/cli/lib/commands/ | grep databases
echo ""
echo "=== Check content of databases.js/twig ==="
if [ -f "templates/cli/lib/commands/databases.js" ]; then
  head -100 templates/cli/lib/commands/databases.js
elif [ -f "templates/cli/lib/commands/databases.js.twig" ]; then
  head -100 templates/cli/lib/commands/databases.js.twig
fi
echo ""
echo "=== Search for the 6 spatial functions in databases file ==="
rg -n 'databasesCreatePointAttribute|databasesUpdatePointAttribute|databasesCreateLineAttribute|databasesUpdateLineAttribute|databasesCreatePolygonAttribute|databasesUpdatePolygonAttribute' templates/cli/lib/commands/databases* -A1Length of output: 240
🏁 Script executed:
#!/bin/bash
# Broad search for databases files
echo "=== Search for all databases-related files ==="
find . -name '*databases*' -type f | grep -v node_modules | head -20
echo ""
echo "=== Search entire codebase for databasesCreatePointAttribute definition ==="
rg -n 'const databasesCreatePointAttribute|function databasesCreatePointAttribute|databasesCreatePointAttribute\s*=' --glob '!**/node_modules/**'
echo ""
echo "=== Search for module.exports in any databases file ==="
rg -n 'module\.exports|exports\.' --glob '!**/node_modules/**' -g '*databases*'Length of output: 329
🏁 Script executed:
#!/bin/bash
# List full directory to see what files exist
echo "=== Full contents of templates/cli/lib/commands/ ==="
find templates/cli/lib/commands/ -type f | sort
echo ""
echo "=== Check if there's a databases.js.twig template ==="
find . -name 'databases.js.twig' 2>/dev/null
echo ""
echo "=== Search for any function named databasesCreatePoint anywhere ==="
rg 'databasesCreatePoint' --glob '!**/node_modules/**'
echo ""
echo "=== Check templates directory structure ==="
ls -la templates/cli/lib/Length of output: 1786
Spatial attribute functions are imported but not exported from databases module
The six spatial functions (databasesCreatePointAttribute, databasesUpdatePointAttribute, databasesCreateLineAttribute, databasesUpdateLineAttribute, databasesCreatePolygonAttribute, databasesUpdatePolygonAttribute) are imported in push.js.twig but do not exist anywhere in the codebase. There is no databases.js.twig template file, and no module exports these functions. The import statement require("./databases") references a module that either doesn't exist or is incomplete. These functions must be defined and exported from a databases module before they can be used in push.js.twig.
🤖 Prompt for AI Agents
In templates/cli/lib/commands/push.js.twig around lines 46 to 51, six spatial
functions are imported from "./databases" but that module does not export them
(and the databases template is missing); implement and export
databasesCreatePointAttribute, databasesUpdatePointAttribute,
databasesCreateLineAttribute, databasesUpdateLineAttribute,
databasesCreatePolygonAttribute, and databasesUpdatePolygonAttribute from the
databases module (create templates/cli/lib/commands/databases.js.twig if
missing) with the expected signatures used by push.js.twig and update the
require path if necessary so push.js.twig imports the module that actually
exports these functions.
What does this PR do?
Screencast.from.2025-10-28.17-26-18.webm
Will solve -> appwrite/sdk-for-cli#210 (comment)
(Provide a description of what this PR does.)
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.)
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