Skip to content

fix(client): default the current database to an empty name - #65

Merged
ChiragAgg5k merged 1 commit into
mainfrom
fix/database-default
Dec 4, 2026
Merged

ChiragAgg5k merged 1 commit into
mainfrom
fix/database-default

Conversation

@ChiragAgg5k

Copy link
Copy Markdown
Member

Follow-up to #64. Subclasses that skip the constructor (test doubles in utopia-php/database and elsewhere) left $database uninitialised, so the new getDatabase() threw an Error on them. utopia-php/database#1107 reads it when constructing the Mongo adapter, which broke those doubles. Defaulting the property to '' makes getDatabase() safe on them; real clients still always set it in the constructor, which refuses an empty name.

Verification: MongoTest::testSetDatabase now also checks a constructor-less double returns ''; the full suite passes locally (63 tests), Pint and PHPStan pass.

Test doubles that extend Client without calling its constructor left the typed property uninitialised, so getDatabase() threw on them; utopia-php/database reads it when building its Mongo adapter.
@coderabbitai

coderabbitai Bot commented Dec 4, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 41 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

Commits

Reviewing files that changed from the base of the PR and between 57313a3 and 0c3e646.

Files selected for processing: 2

  • src/Client.php
  • tests/MongoTest.php
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@appwrite

appwrite Bot commented Dec 4, 2026 •

Copy link
Copy Markdown

Code review

Commit Status Tier Verdict Details
0c3e646 Reviewed Reviewed 🟢 S · Ready to merge ✅ Approved View review

The default addresses the constructor-less subclass case, and the added test covers the changed behavior.

The client’s database-name property now defaults to an empty string when a subclass skips the constructor, while normal construction still assigns the validated database name. The Mongo test adds coverage for getDatabase() on a constructor-less subclass.

Walkthrough (2)
File Change
src/Client.php Initialize the database-name property to an empty string for subclasses that skip construction.
tests/MongoTest.php Verify that a constructor-less Client subclass returns an empty database name.

Reviewed 0c3e646

Tip

Comment @appwrite review to re-run, or mention @appwrite with a question.

@appwrite appwrite Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Tier S · Looks good to merge. Summary

@ChiragAgg5k
ChiragAgg5k merged commit 135413e into main Dec 4, 2026
5 checks passed
@ChiragAgg5k
ChiragAgg5k deleted the fix/database-default branch December 4, 2026 20:28
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.

1 participant