-
Notifications
You must be signed in to change notification settings - Fork 3
Joins #133
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
base: main
Are you sure you want to change the base?
Joins #133
Changes from all commits
1d86a6b
ae04b11
98dd145
01e06cf
6a95abb
f2c5f6a
53ce92c
67c8eda
69ade1c
066bd70
49bddeb
f50c5ad
805bdb8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ | |
|
|
||
| namespace Utopia\Migration\Sources\Appwrite; | ||
|
|
||
| use Utopia\Database\Query; | ||
| use Utopia\Migration\Resource; | ||
| use Utopia\Migration\Resources\Database\Database; | ||
| use Utopia\Migration\Resources\Database\Table; | ||
|
|
@@ -78,10 +79,10 @@ public function getRow(Table $resource, string $rowId, array $queries = []): arr | |
| /** | ||
| * Return a query to select the given attributes | ||
| * | ||
| * @param array $columns | ||
| * @param string $column | ||
| * @return QueryType|string | ||
| */ | ||
| public function querySelect(array $columns): mixed; | ||
| public function querySelect(string $column): mixed; | ||
|
Comment on lines
+82
to
+85
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interface signature change looks correct, but API.php implementation has issues. The interface change from
public function querySelect(string $column): string
{
return new Query('select', $column); // Returns Query object, not string
/**
* todo fix Query::select to get attribute not array
*/
return Query::select($column); // Unreachable
}Please fix the API.php implementation to either return a string (e.g., the query string representation) or correct the return type declaration. 🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
| * Return a query to filter the given attributes | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -212,12 +212,17 @@ public function getRow(Table $resource, string $rowId, array $queries = []): arr | |
| } | ||
|
|
||
| /** | ||
| * @param array $columns | ||
| * @return string | ||
| * @param string $column | ||
| * @return Query | ||
| */ | ||
| public function querySelect(array $columns): string | ||
| public function querySelect(string $column): string | ||
| { | ||
| return Query::select($columns); | ||
| return new Query('select', $column); | ||
|
|
||
| /** | ||
| * todo fix Query::select to get attribute not array | ||
| */ | ||
| return Query::select($column); | ||
| } | ||
|
Comment on lines
214
to
226
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # First, let's examine the file structure and the actual code
find . -name "API.php" -path "*/Migration/Sources/Appwrite/Reader/*" | head -5Repository: utopia-php/migration Length of output: 111 🏁 Script executed: # Check the exact code at those lines
if [ -f "src/Migration/Sources/Appwrite/Reader/API.php" ]; then
sed -n '200,225p' src/Migration/Sources/Appwrite/Reader/API.php
fiRepository: utopia-php/migration Length of output: 601 🏁 Script executed: # Look at similar methods in the same file to understand the pattern
if [ -f "src/Migration/Sources/Appwrite/Reader/API.php" ]; then
rg -n "public function query" src/Migration/Sources/Appwrite/Reader/API.php -A 8
fiRepository: utopia-php/migration Length of output: 973 🏁 Script executed: # Search for Appwrite Query imports or usage
rg -n "Query" src/Migration/Sources/Appwrite/Reader/API.php | head -20Repository: utopia-php/migration Length of output: 609 🏁 Script executed: # Check what version of Appwrite is being used (composer.json)
if [ -f "composer.json" ]; then
cat composer.json | jq '.require | select(. != null) | to_entries[] | select(.key | contains("appwrite"))'
fiRepository: utopia-php/migration Length of output: 115 🌐 Web query:
💡 Result: The Query.select operator is documented on the Appwrite Queries page — it lets you specify which columns/relationship fields to return (you can pass a single name or an array). Use it with SDK list endpoints via the queries parameter. Example (PHP, Appwrite 15.x): listDocuments( databaseId: '', collectionId: '', queries: [ Query::select(['name','email']), // select specific fields ] ); Docs: - Queries / Select operator (Appwrite docs). [1] - Databases PHP reference (showing use of queries parameter). [2] Sources: [1] https://appwrite.io/docs/products/databases/queries [2] https://appwrite.io/docs/references/cloud/server-php/databases --- 🌐 Web query: `Appwrite PHP SDK Query class static methods documentation` 💡 Result: Here are the main static query helper methods provided by Appwrite SDKs (available via Appwrite\Query in PHP). Use them to build the queries[] array passed to list/read endpoints: - Selection: select(...) - Comparison: equal(...), notEqual(...), less(...), lessEqual(...), greater(...), greaterEqual(...), between(...), notBetween(...) - Null checks: isNull(...), isNotNull(...) - String/array ops: startsWith(...), notStartsWith(...), endsWith(...), notEndsWith(...), contains(...), notContains(...), search(...), notSearch(...) - Logical: AND (by passing an array of subqueries), OR (multiple values in a method) - Ordering: orderAsc(...), orderDesc(...), orderRandom() - Pagination/cursors: limit(...), offset(...), cursorAfter(...), cursorBefore(...) - Time helpers: createdBefore(...), createdAfter(...), updatedBefore(...), updatedAfter(...) - Geo / spatial: distanceEqual(...), distanceNotEqual(...), distanceGreater(...), distanceLess(...), intersects(...), notIntersects(...), overlaps(...), notOverlaps(...), touches(...) - Others / patterns: (supports selecting relationship fields, wildcards, etc.) For full details, examples and exact signatures see the Appwrite Queries docs and the PHP quick-start examples. [1][2] Sources: [1] Appwrite — Queries documentation. [2] Appwrite — PHP quick start / Query examples. ---Proposed fix```diff /** * @param string $column - * @return Query + * @return string */ public function querySelect(string $column): string { - return new Query('select', $column); - - /** - * todo fix Query::select to get attribute not array - */ - return Query::select($column); + return Query::select($column); } ```🧰 Tools🪛 GitHub Actions: CodeQL[error] 211-211: PHPStan: PHPDoc tag @return with type Appwrite\Query is incompatible with native type string.🤖 Prompt for AI Agents``` In @src/Migration/Sources/Appwrite/Reader/API.php around lines 207 - 219, The querySelect method currently returns a Query object via new Query('select', $column) while its native signature declares : string and the PHPDoc says @return Query; replace the implementation to mirror other methods by returning the static string form Query::select($column), update the native return type to string (or adjust PHPDoc if you intentionally want a Query object), and remove the unreachable/new Query(...) code so querySelect consistently returns a string like the other query* methods. ``` |
||
|
|
||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -360,12 +360,12 @@ public function getRow(TableResource $resource, string $rowId, array $queries = | |
| } | ||
|
|
||
| /** | ||
| * @param array $columns | ||
| * @param string $column | ||
| * @return Query | ||
| */ | ||
| public function querySelect(array $columns): Query | ||
| public function querySelect(string $column): Query | ||
| { | ||
| return Query::select($columns); | ||
| return Query::select($column); | ||
| } | ||
|
Comment on lines
362
to
369
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: # Search for Query class definition and select method
find . -type f -name "*.php" | head -20 | xargs grep -l "class Query" 2>/dev/null | grep -v node_modules | grep -v vendorRepository: utopia-php/migration Length of output: 46 🏁 Script executed: # Search for select method in Query class more broadly
rg "class Query|function select\(|public static function select" --type php -A 3 -B 1 | head -100Repository: utopia-php/migration Length of output: 46 🏁 Script executed: # Look for Query import in the Database.php file to understand where it comes from
rg "use.*Query|import.*Query" src/Migration/Sources/Appwrite/Reader/Database.phpRepository: utopia-php/migration Length of output: 90 🏁 Script executed: # Check composer.json for utopia-php/database dependency
cat composer.json | grep -A 2 -B 2 "utopia-php/database" || head -30 composer.jsonRepository: utopia-php/migration Length of output: 255 🌐 Web query:
💡 Result: Signature: Query::select(array $attributes) — accepts an array of attribute names to return (e.g. Query::select(['name','year'])). [1][2] Sources:
Fix The implementation passes a single string to return Query::select([$column]);🤖 Prompt for AI Agents |
||
|
|
||
| /** | ||
|
|
||
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
🏁 Script executed:
# Read the full composer.json to understand context cat composer.jsonRepository: utopia-php/migration
Length of output: 1443
🏁 Script executed:
Repository: utopia-php/migration
Length of output: 233
🏁 Script executed:
Repository: utopia-php/migration
Length of output: 86
🏁 Script executed:
Repository: utopia-php/migration
Length of output: 1725
🏁 Script executed:
Repository: utopia-php/migration
Length of output: 79
🏁 Script executed:
Repository: utopia-php/migration
Length of output: 46
🏁 Script executed:
Repository: utopia-php/migration
Length of output: 46
Remove the dev dependency before release.
This library uses
dev-joins8 as 4.5.2for the database package, which violates the"minimum-stability": "stable"requirement and will force consumers to accept an unreleased development branch. Once thejoins8branch is merged and released as a stable version inutopia-php/database, revert this to the stable version constraint (e.g.,"4.*"or the specific tagged release).Add a TODO comment in
composer.jsonor create a tracking issue to ensure this change doesn't ship to production.🤖 Prompt for AI Agents