Skip to content

Conversation

@shimonewman
Copy link
Contributor

@shimonewman shimonewman commented Sep 14, 2025

Summary by CodeRabbit

  • New Features

    • Added MongoDB database adapter, enabling full CRUD, indexing, and query support.
    • Docker image now includes the MongoDB PHP extension; docker-compose adds Mongo and Mongo Express for local use.
    • Introduced UUIDv7 identifier support across validation and workflows.
  • Tests

    • Added end-to-end suites for MongoDB and Shared Tables; adjusted tests for adapter-specific limits and capabilities.
  • Chores

    • CI expanded to run adapter tests for MongoDB and Shared Tables; PHPUnit now stops on first failure.

shimonewman and others added 30 commits June 25, 2025 20:06
# Conflicts:
#	tests/e2e/Adapter/Scopes/DocumentTests.php
# Conflicts:
#	docker-compose.yml
#	src/Database/Database.php
#	tests/e2e/Adapter/Scopes/AttributeTests.php
…ocuments, improving sequence retrieval logic and preserving document structure.
…uments for sequences without existing IDs, and update index length checks in tests to align with maximum index length constraints.
…files to improve code readability and maintainability.
… mapping in index definitions. Update attribute filtering logic to directly modify the attributes array for improved clarity and maintainability.
…-tmp-pulls

# Conflicts:
#	src/Database/Adapter/Pool.php
#	src/Database/Adapter/SQL.php
#	src/Database/Database.php
…s, improve error handling, and update comments for clarity. Disable Client.php binding in docker-compose for cleaner setup.
…nation and accurate document counting using aggregation. Improved error handling and added comments for clarity.
…Mongo adapter and uncomment test cases for notBetween functionality in DocumentTests, enhancing test coverage for various scenarios.
…-tmp-pulls

# Conflicts:
#	composer.lock
#	src/Database/Database.php
…DB integration. Cleaned up code in Database.php for better cursor encoding and ensured proper initialization. Adjusted DocumentTests for improved readability and consistency.
…porarily disable it for further review and refinement.
…rading utopia-php/mongo to version 0.6.0, brick/math to 0.14.0, and open-telemetry/api to 1.5.0. Added symfony/polyfill-php83 for compatibility with PHP 8.3 features. Updated phpunit to version 9.6.26 and utopia-php/framework to 0.33.27.
…-tmp-pulls

# Conflicts:
#	src/Database/Adapter/Pool.php
#	src/Database/Adapter/SQL.php
…method and implemented support checks for spatial axis order and distance calculations between multi-dimension geometries.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 14, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds MongoDB support: new Mongo adapter, Docker/compose setup, Composer dependency, CI matrix updates, and E2E tests. Database core now invokes adapter castingBefore/castingAfter and handles DATETIME via adapter->isMongo()/setUTCDatetime. Public API changes include Adapter interface updates, Database constant rename to VAR_UUID7, and query converters made instance methods.

Changes

Cohort / File(s) Summary
CI adapter matrix
.github/workflows/tests.yml
Added MongoDB and SharedTables/MongoDB adapters to test matrix.
Container build/runtime
Dockerfile, docker-compose.yml
Dockerfile: adds PHP MongoDB extension via PHP_MONGODB_VERSION=1.21.1. Compose: adds mongo and mongo-express services; minor commented test volume.
Dependency management
composer.json
Adds utopia-php/mongo (require) and suggests mongodb/mongodb.
PHPUnit behavior
phpunit.xml
Sets stopOnFailure="true".
Adapter interface and implementations
src/Database/Adapter.php, src/Database/Adapter/Mongo.php, src/Database/Adapter/SQL.php, src/Database/Adapter/Pool.php
Adapter: replaces getTenantQuery with isMongo; adds casting hooks, internal-casting capability, UTC datetime setter. New Mongo adapter implementing full CRUD, indexing, queries, capability flags, casting, and tenant filters. SQL/Pool add corresponding methods (no-op/defaults in SQL; delegation in Pool).
Database core flow
src/Database/Database.php
Renames VAR_OBJECT_IDVAR_UUID7; converts query helpers to instance methods; injects adapter castingBefore/After around CRUD and batch paths; DATETIME handling branches on isMongo() with setUTCDatetime().
Validators
src/Database/Validator/Key.php, src/Database/Validator/Sequence.php
Key: comment only. Sequence: switch ID validation from ObjectId to UUIDv7 regex.
E2E tests — Mongo adapters
tests/e2e/Adapter/MongoDBTest.php, tests/e2e/Adapter/SharedTables/MongoDBTest.php
Add Mongo and SharedTables/Mongo test suites with Redis-backed cache setup and Mongo connection; include basic lifecycle and placeholder attribute tests.
E2E tests — scopes
tests/e2e/Adapter/Scopes/AttributeTests.php, .../CollectionTests.php, .../DocumentTests.php, .../IndexTests.php, .../PermissionTests.php
Attribute/Index: use dynamic max-index values; Collection: adjust an index definition; Document: dynamic sequences for UUID7 vs numeric; remove several “not” tests; Permission: skip relationship tests if unsupported.
Unit tests
tests/unit/Validator/StructureTest.php
Update ID validation to UUIDv7 and constant usage.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Client
  participant Database
  participant Adapter as Adapter (SQL/Mongo)
  participant Store as Backend Store

  rect rgba(230,240,255,0.4)
  note over Database,Adapter: Create/Update flow with casting
  Client->>Database: createDocument(collection, doc)
  Database->>Adapter: castingBefore(collection, doc)
  Adapter-->>Database: doc'
  Database->>Adapter: createDocument(collection, doc')
  Adapter->>Store: Persist
  Store-->>Adapter: Stored doc
  Adapter-->>Database: stored doc
  Database->>Adapter: castingAfter(collection, stored doc)
  Adapter-->>Database: doc''
  Database-->>Client: doc''
  end

  rect rgba(240,255,230,0.4)
  note over Database,Adapter: Read flow with casting
  Client->>Database: getDocument(collection, id)
  Database->>Adapter: getDocument(collection, id)
  Adapter->>Store: Fetch
  Store-->>Adapter: doc
  Adapter-->>Database: doc
  Database->>Adapter: castingAfter(collection, doc)
  Adapter-->>Database: doc'
  Database-->>Client: doc'
  end

  rect rgba(255,245,230,0.4)
  note over Database,Adapter: DATETIME normalization
  Database->>Adapter: isMongo()
  alt Mongo
    Database->>Adapter: setUTCDatetime(value)
  else SQL-like
    Database->>Database: DateTime::setTimezone(UTC)
  end
  end
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Possibly related PRs

Poem

I hop through docs and tests with glee,
A carrot-shaped key for Mongo DB. 🥕
Casting before, casting after—so neat,
UUID7 drums a brand-new beat.
In docker burrows, services grow,
Green lights blink—onward we go!
Thump-thump—ship it, yo! 🚀🐇

✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat-mongo-tmp-pulls

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e68f2e3 and 15c04b9.

⛔ Files ignored due to path filters (1)
  • composer.lock is excluded by !**/*.lock
📒 Files selected for processing (20)
  • .github/workflows/tests.yml (1 hunks)
  • Dockerfile (2 hunks)
  • composer.json (2 hunks)
  • docker-compose.yml (2 hunks)
  • phpunit.xml (1 hunks)
  • src/Database/Adapter.php (1 hunks)
  • src/Database/Adapter/Mongo.php (1 hunks)
  • src/Database/Adapter/Pool.php (1 hunks)
  • src/Database/Adapter/SQL.php (1 hunks)
  • src/Database/Database.php (15 hunks)
  • src/Database/Validator/Key.php (1 hunks)
  • src/Database/Validator/Sequence.php (1 hunks)
  • tests/e2e/Adapter/MongoDBTest.php (1 hunks)
  • tests/e2e/Adapter/Scopes/AttributeTests.php (2 hunks)
  • tests/e2e/Adapter/Scopes/CollectionTests.php (1 hunks)
  • tests/e2e/Adapter/Scopes/DocumentTests.php (11 hunks)
  • tests/e2e/Adapter/Scopes/IndexTests.php (2 hunks)
  • tests/e2e/Adapter/Scopes/PermissionTests.php (2 hunks)
  • tests/e2e/Adapter/SharedTables/MongoDBTest.php (1 hunks)
  • tests/unit/Validator/StructureTest.php (2 hunks)

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


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.

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.

4 participants