Skip to content

added a fallback isnulll#11628

Merged
abnegate merged 3 commits into1.9.xfrom
patch-list-db
Mar 24, 2026
Merged

added a fallback isnulll#11628
abnegate merged 3 commits into1.9.xfrom
patch-list-db

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 Mar 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b3a999ba-0c08-4a4f-a43c-d60c8aaa9b15

📥 Commits

Reviewing files that changed from the base of the PR and between 9e59558 and 2b33dc3.

📒 Files selected for processing (1)
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/XList.php
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/XList.php

📝 Walkthrough

Walkthrough

The pull request changes how type filters are constructed in two database-listing modules. In Databases/XList.php getDatabaseTypeQueryFilters() now returns a structured query filter and those filter entries are merged into the parsed $queries array so the same assembled queries are used for both find() and count(). In TablesDB/XList.php getDatabaseTypeQueryFilters() now builds a Query::or filter that matches multiple type values or null and adds the Utopia\Database\Query import. No public method signatures were changed.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

🚥 Pre-merge checks | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description contains only a template with placeholder sections and no actual implementation details, test information, or explanation of the changes made. Provide a concrete description of what the changes do, why they're needed, and how to test them. Remove or fill in the template placeholders with actual details about the query filter refactoring.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'added a fallback isnulll' is vague and does not clearly convey the actual changes made. The PR modifies query filter logic in two database files, but the title is unclear and appears to contain a typo. Revise the title to clearly describe the main change, such as 'Refactor database type query filters to use structured queries' or 'Fix null handling in database type filters'.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch patch-list-db

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.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 24, 2026

Greptile Summary

This PR adds an isNull('type') fallback to the TablesDB database listing query so that legacy databases without a type field are included in results. However, the refactor in Databases/XList.php introduces two critical regressions that break the listing endpoint.

Key changes and issues:

  • Critical – user queries silently dropped: find() now receives only the output of getDatabaseTypeQueryFilters(). The user-supplied $queries array (search terms, cursor, ordering, limit, etc.) is never passed to find(), so pagination, search, and ordering are completely non-functional.
  • Critical – type filter missing from count(): count() still uses the raw $queries array without the type-filter query, so the returned total count includes databases of all types rather than only the filtered set. For the TablesDB endpoint this means the total will be inflated.
  • Style – indentation: The getDatabaseTypeQueryFilters() method body in TablesDB/XList.php is incorrectly indented at column 0 instead of being inside the class indentation level.

The fix is to merge the type-filter queries into $queries and pass the combined array to both find() and count().

Confidence Score: 1/5

  • Not safe to merge — the refactor breaks pagination, search, and the total count for all database listing endpoints.
  • Two separate critical regressions are introduced in the same action() method: user-provided queries are no longer passed to find() (breaking search, cursor pagination, ordering, and limits), and the type filter is no longer applied to count() (returning an incorrect total). These affect all callers of the affected endpoints.
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/XList.php requires the most attention — both find() and count() calls need to use the merged query set.

Important Files Changed

Filename Overview
src/Appwrite/Platform/Modules/Databases/Http/Databases/XList.php Refactor drops user-provided queries from find() (breaking pagination/search) and removes the type filter from count() (breaking the total count).
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/XList.php Adds isNull('type') fallback via Query::or — correct intent — but introduces a formatting error (method body not indented inside the class).

Reviews (1): Last reviewed commit: "added a fallback isnulll" | Re-trigger Greptile

Comment on lines 100 to 101
$databases = $dbForProject->find('databases', $this->getDatabaseTypeQueryFilters());
$total = $includeTotal ? $dbForProject->count('databases', $queries, APP_LIMIT_COUNT) : 0;
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.

P2 User-provided queries dropped from find(), type filter missing from count()

The refactor introduces two separate regressions:

  1. find() now only receives getDatabaseTypeQueryFilters() — the user-supplied $queries array (which carries search terms, cursor pagination, ordering, limits, etc.) is completely discarded. This means pagination, search, and ordering no longer work for the listing endpoint.

  2. count() still uses the original $queries but no longer includes the type filter. For the TablesDB subclass this means the returned total would count all databases regardless of type, causing the total count to be incorrect.

The type-filter query needs to be merged into $queries so that both calls receive the full combined set:

$typeFilters = $this->getDatabaseTypeQueryFilters();
$allQueries  = array_merge($queries, $typeFilters);

try {
    $databases = $dbForProject->find('databases', $allQueries);
    $total = $includeTotal ? $dbForProject->count('databases', $allQueries, APP_LIMIT_COUNT) : 0;
}

Comment on lines +24 to +32
protected function getDatabaseTypeQueryFilters(): array
{
return [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY];
}
{
return [
Query::or([
Query::equal('type', [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY]),
Query::isNull('type'),
]),
];
}
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.

P2 Incorrect indentation on method body

The opening brace { and method body are indented at column 0 instead of being aligned with the class body (4 spaces). This breaks the code's formatting conventions.

Suggested change
protected function getDatabaseTypeQueryFilters(): array
{
return [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY];
}
{
return [
Query::or([
Query::equal('type', [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY]),
Query::isNull('type'),
]),
];
}
protected function getDatabaseTypeQueryFilters(): array
{
return [
Query::or([
Query::equal('type', [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY]),
Query::isNull('type'),
]),
];
}

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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: 1

🧹 Nitpick comments (1)
src/Appwrite/Platform/Modules/Databases/Http/TablesDB/XList.php (1)

24-32: Fix method indentation to comply with PSR-12.

The method body is not indented within the class. The opening brace should be on the same line or next line with proper indentation, and the body should be indented consistently.

🔧 Proposed formatting fix
     protected function getDatabaseTypeQueryFilters(): array
-{
-    return [
-        Query::or([
-            Query::equal('type', [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY]),
-            Query::isNull('type'),
-        ]),
-    ];
-}
+    {
+        return [
+            Query::or([
+                Query::equal('type', [DATABASE_TYPE_TABLESDB, DATABASE_TYPE_LEGACY]),
+                Query::isNull('type'),
+            ]),
+        ];
+    }

As per coding guidelines: "Follow PSR-12 coding standard".

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/Appwrite/Platform/Modules/Databases/Http/TablesDB/XList.php` around lines
24 - 32, Adjust the method indentation for getDatabaseTypeQueryFilters in class
XList to comply with PSR-12: place the opening brace on the same line as the
method declaration or on the next line, then indent the method body one level
inside the class and align the return array elements consistently (ensure
Query::or and its nested entries are indented). Update only the
whitespace/formatting of getDatabaseTypeQueryFilters so the signature, brace,
and return block follow PSR-12 indentation rules.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/Appwrite/Platform/Modules/Databases/Http/Databases/XList.php`:
- Around line 100-101: The current calls to $dbForProject->find('databases',
...) and ->count('databases', ...) are using different filter sets causing user
queries (pagination, search, filters in $queries) and type filters (from
getDatabaseTypeQueryFilters()) to be applied inconsistently; fix by merging the
two filter arrays into a single filter set and use that for both operations
(e.g., combine $queries with $this->getDatabaseTypeQueryFilters() into $filters)
so that $dbForProject->find('databases', $filters) applies
cursor/pagination/search/filters and $dbForProject->count('databases', $filters,
APP_LIMIT_COUNT) applies the same type constraints for correct total counts.

---

Nitpick comments:
In `@src/Appwrite/Platform/Modules/Databases/Http/TablesDB/XList.php`:
- Around line 24-32: Adjust the method indentation for
getDatabaseTypeQueryFilters in class XList to comply with PSR-12: place the
opening brace on the same line as the method declaration or on the next line,
then indent the method body one level inside the class and align the return
array elements consistently (ensure Query::or and its nested entries are
indented). Update only the whitespace/formatting of getDatabaseTypeQueryFilters
so the signature, brace, and return block follow PSR-12 indentation rules.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 72f2f747-2a8b-402f-9d81-36b9233bdd2b

📥 Commits

Reviewing files that changed from the base of the PR and between d4f7d51 and 20bd7af.

📒 Files selected for processing (2)
  • src/Appwrite/Platform/Modules/Databases/Http/Databases/XList.php
  • src/Appwrite/Platform/Modules/Databases/Http/TablesDB/XList.php

@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 24, 2026

🔄 PHP-Retry Summary

Flaky tests detected across commits:

Commit 2b33dc3 - 5 flaky tests
Test Retries Total Time Details
LegacyConsoleClientTest::testTimeout 1 120.73s Logs
LegacyCustomClientTest::testCreateIndexes 1 242.55s Logs
LegacyCustomServerTest::testTimeout 1 120.98s Logs
LegacyTransactionsConsoleClientTest::testTransactionExpiration 1 240.38s Logs
UsageTest::testVectorsDBStats 1 10.06s Logs

@github-actions
Copy link
Copy Markdown

✨ Benchmark results

  • Requests per second: 1,676
  • Requests with 200 status code: 301,690
  • P99 latency: 0.104419901

⚡ Benchmark Comparison

Metric This PR Latest version
RPS 1,676 1,124
200 301,690 202,374
P99 0.104419901 0.199859344

@blacksmith-sh

This comment has been minimized.

@abnegate abnegate merged commit 49688a6 into 1.9.x Mar 24, 2026
76 of 80 checks passed
@abnegate abnegate deleted the patch-list-db branch March 24, 2026 11:01
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