Skip to content

Conversation

@fogelito
Copy link
Contributor

@fogelito fogelito commented Jul 13, 2025

Previous PR
#243

Summary by CodeRabbit

  • New Features

    • Introduced support for a new id attribute type with explicit validation for integer and string (MongoDB ObjectId) formats.
    • Enabled collections and documents to include and index the new id attribute type.
    • Added sequence value validation tied to the id attribute type.
    • Database adapters now recognize and handle the new id attribute type with appropriate SQL type mappings.
  • Bug Fixes

    • Improved handling of tenant and sequence fields for consistent data typing and validation.
  • Tests

    • Extended test coverage for the id attribute type, including creation, querying, edge cases (null, zero), and validation behavior across different ID types.
    • Updated validators and query tests to incorporate the new id attribute type.
  • Documentation

    • Clarified attribute type definitions and validation logic through updated in-code comments.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jul 13, 2025

Walkthrough

These changes introduce a new attribute type, VAR_ID, to the database schema and validation system, supporting both integer and MongoDB-style string IDs. The update adds new constants, validation logic, and methods to handle this type across adapters, validators, and the core Database class. Tests are extended to cover the new id attribute and its validation.

Changes

File(s) Change Summary
Adapter ID Type Methods
src/Database/Adapter.php, src/Database/Adapter/SQL.php, src/Database/Adapter/Pool.php
Added abstract method getIdAttributeType() in Adapter and implemented it in SQL and Pool classes to specify the ID attribute type.
Adapter SQL Type Handling
src/Database/Adapter/MariaDB.php, src/Database/Adapter/Postgres.php
Added VAR_ID case in getSQLType method returning appropriate SQL types (BIGINT UNSIGNED for MariaDB, BIGINT for Postgres).
Core Database Class
src/Database/Database.php
Added constants VAR_ID and VAR_OBJECT_ID; updated internal attributes, validation, casting, and passed ID type to validators and structures in multiple methods.
Validators - Queries and Filters
src/Database/Validator/Queries/Documents.php, src/Database/Validator/Query/Filter.php
Updated constructors to require and use ID attribute type; extended validation logic for VAR_ID including passing ID type to Filter and Sequence validators.
New Sequence Validator
src/Database/Validator/Sequence.php
Added new Sequence validator class for validating sequence (ID) values with support for integer and MongoDB string types, enforcing format and range rules.
Structure Validator
src/Database/Validator/Structure.php
Added ID type parameter; changed $sequence attribute type to VAR_ID; added Sequence validator for VAR_ID attributes.
Tests - E2E Attribute and Collection Scopes
tests/e2e/Adapter/Scopes/AttributeTests.php, tests/e2e/Adapter/Scopes/CollectionTests.php
Updated tests to create, index, and delete id attributes of type VAR_ID.
Tests - E2E Document Scopes
tests/e2e/Adapter/Scopes/DocumentTests.php
Extended document tests for id attribute, including null, zero, and invalid sequence cases, asserting correct validation and retrieval behavior.
Tests - Unit Structure Validator
tests/unit/Validator/StructureTest.php
Added id attribute and tests for both integer and MongoDB ID types in structure validator; updated existing tests to specify ID attribute type.
Tests - Unit Query Validators
tests/unit/Validator/DocumentsQueriesTest.php, tests/unit/Validator/IndexedQueriesTest.php, tests/unit/Validator/QueriesTest.php, tests/unit/Validator/Query/FilterTest.php, tests/unit/Validator/QueryTest.php
Updated validator instantiations to specify ID attribute type; added queries involving id attribute; no changes to test logic or assertions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Database
    participant Adapter
    participant Validator

    Client->>Database: createDocument(collection, document)
    Database->>Adapter: getIdAttributeType()
    Adapter-->>Database: VAR_ID_INT or VAR_ID_MONGO
    Database->>Validator: new Structure(attributes, idAttributeType)
    Validator->>Validator: Validate 'id' attribute with Sequence(idAttributeType)
    Validator-->>Database: Validation result
    Database-->>Client: Document created or error
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~45 minutes

Poem

(\(\
( -.-)
o_(")(")

A hop and a skip, a new ID in tow,
Now strings or numbers, our database will know.
With tests and with checks, validation runs deep—
The rabbit ensures your data’s not cheap!
Sequence or string, let your IDs sing.
Hooray for the changes this pull did bring!

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ab1d5c8 and 7d77337.

📒 Files selected for processing (12)
  • src/Database/Adapter.php (1 hunks)
  • src/Database/Adapter/MariaDB.php (1 hunks)
  • src/Database/Adapter/Postgres.php (1 hunks)
  • src/Database/Adapter/SQL.php (2 hunks)
  • src/Database/Database.php (15 hunks)
  • src/Database/Validator/Sequence.php (1 hunks)
  • tests/unit/Validator/DocumentsQueriesTest.php (4 hunks)
  • tests/unit/Validator/IndexedQueriesTest.php (3 hunks)
  • tests/unit/Validator/QueriesTest.php (1 hunks)
  • tests/unit/Validator/Query/FilterTest.php (1 hunks)
  • tests/unit/Validator/QueryTest.php (10 hunks)
  • tests/unit/Validator/StructureTest.php (23 hunks)
🚧 Files skipped from review as they are similar to previous changes (12)
  • tests/unit/Validator/StructureTest.php
  • tests/unit/Validator/DocumentsQueriesTest.php
  • src/Database/Adapter/MariaDB.php
  • src/Database/Validator/Sequence.php
  • tests/unit/Validator/QueriesTest.php
  • tests/unit/Validator/QueryTest.php
  • src/Database/Adapter/Postgres.php
  • src/Database/Adapter/SQL.php
  • tests/unit/Validator/Query/FilterTest.php
  • src/Database/Database.php
  • tests/unit/Validator/IndexedQueriesTest.php
  • src/Database/Adapter.php
⏰ 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). (1)
  • GitHub Check: Adapter Tests (Mirror)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch primary-attribute

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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: 4

🔭 Outside diff range comments (2)
src/Database/Database.php (2)

1812-1812: Update error message to include new attribute types

The error message should be updated to include the new VAR_ID and VAR_SEQUENCE types in the list of valid attribute types.

-throw new DatabaseException('Unknown attribute type: ' . $type . '. Must be one of ' . self::VAR_STRING . ', ' . self::VAR_INTEGER . ', ' . self::VAR_FLOAT . ', ' . self::VAR_BOOLEAN . ', ' . self::VAR_DATETIME . ', ' . self::VAR_RELATIONSHIP);
+throw new DatabaseException('Unknown attribute type: ' . $type . '. Must be one of ' . self::VAR_STRING . ', ' . self::VAR_INTEGER . ', ' . self::VAR_FLOAT . ', ' . self::VAR_BOOLEAN . ', ' . self::VAR_DATETIME . ', ' . self::VAR_ID . ', ' . self::VAR_SEQUENCE . ', ' . self::VAR_RELATIONSHIP);

1867-1883: Add validation for new attribute types in validateDefaultTypes

The validateDefaultTypes method should handle the new VAR_ID and VAR_SEQUENCE types. Currently, these types will fall through to the default case and throw an exception when setting default values.

Consider adding cases for these new types or updating the error message to include them in the list of valid types.

🧹 Nitpick comments (2)
src/Database/Adapter/SQL.php (1)

1585-1591: Add documentation for the new method.

The implementation correctly fulfills the abstract method contract from the parent Adapter class. However, consider adding a PHPDoc comment for consistency with other methods in the class.

+    /**
+     * Get the primitive type used for ID attributes in this SQL adapter
+     *
+     * @return string
+     */
     public function getIdAttributeType(): string
     {
         return 'int';
     }
src/Database/Validator/Structure.php (1)

53-53: Address the uncertainty comment for $tenant attribute type.

The comment // ????? suggests uncertainty about the $tenant attribute type. This should be clarified or removed before merging.

Would you like me to help determine the correct type for the $tenant attribute or open an issue to track this?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb2f759 and 0902764.

📒 Files selected for processing (13)
  • phpunit.xml (1 hunks)
  • src/Database/Adapter.php (1 hunks)
  • src/Database/Adapter/MariaDB.php (1 hunks)
  • src/Database/Adapter/Postgres.php (1 hunks)
  • src/Database/Adapter/SQL.php (2 hunks)
  • src/Database/Database.php (8 hunks)
  • src/Database/Validator/Queries/Documents.php (1 hunks)
  • src/Database/Validator/Query/Filter.php (2 hunks)
  • src/Database/Validator/Sequence.php (1 hunks)
  • src/Database/Validator/Structure.php (4 hunks)
  • tests/e2e/Adapter/Scopes/AttributeTests.php (4 hunks)
  • tests/e2e/Adapter/Scopes/CollectionTests.php (3 hunks)
  • tests/e2e/Adapter/Scopes/DocumentTests.php (5 hunks)
🧰 Additional context used
🧠 Learnings (1)
src/Database/Adapter/Postgres.php (1)
Learnt from: ArnabChatterjee20k
PR: utopia-php/database#613
File: src/Database/Adapter/Postgres.php:1254-1319
Timestamp: 2025-07-01T11:31:37.438Z
Learning: In PostgreSQL adapter methods like getUpsertStatement, complexity for database-specific SQL generation is acceptable when the main business logic is properly separated in the parent SQL adapter class, following the adapter pattern where each database adapter handles its own SQL syntax requirements.
🧬 Code Graph Analysis (4)
src/Database/Adapter.php (1)
src/Database/Adapter/SQL.php (1)
  • getIdAttributeType (1588-1591)
src/Database/Adapter/Postgres.php (1)
src/Database/Database.php (1)
  • Database (35-6800)
src/Database/Adapter/SQL.php (2)
src/Database/Database.php (1)
  • Database (35-6800)
src/Database/Adapter.php (1)
  • getIdAttributeType (862-862)
src/Database/Database.php (2)
src/Database/Adapter/SQL.php (1)
  • getIdAttributeType (1588-1591)
src/Database/Adapter.php (1)
  • getIdAttributeType (862-862)
🪛 GitHub Actions: Linter
src/Database/Validator/Sequence.php

[error] 1-1: PHP CS Fixer (Pint) PSR-12 style check failed: 'elseif' construct must have single space around it.

⏰ 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). (1)
  • GitHub Check: Setup & Build Docker Image
🔇 Additional comments (20)
phpunit.xml (1)

10-10: LGTM! Good practice for catching new feature issues early.

The change to stop test execution on first failure is appropriate when introducing new features like VAR_ID and VAR_SEQUENCE types, ensuring immediate feedback on any issues.

src/Database/Validator/Queries/Documents.php (1)

41-41: Excellent semantic improvement.

Changing the $sequence attribute type from VAR_STRING to VAR_SEQUENCE provides better type safety and aligns with the introduction of dedicated sequence handling in the system.

src/Database/Adapter.php (1)

857-862: Well-designed abstraction for adapter-specific ID handling.

The new getIdAttributeType() abstract method provides a clean way for different database adapters to specify their ID attribute primitive type, enabling proper validation and type handling across the system.

src/Database/Adapter/MariaDB.php (1)

1907-1908: Appropriate SQL type mapping for MariaDB.

The VAR_ID case returning 'bigint UNSIGNED' is well-suited for MariaDB ID columns, providing sufficient range while maintaining unsigned constraint for positive ID values.

src/Database/Adapter/SQL.php (1)

1006-1009: LGTM: Correct attribute width calculation for new types.

The addition of VAR_SEQUENCE and VAR_ID attribute types with 8-byte width allocation is correct for BIGINT storage. The fall-through case structure is properly implemented with the shared logic and break statement.

src/Database/Adapter/Postgres.php (1)

1820-1822: LGTM! Appropriate SQL type mapping for the new VAR_ID attribute type.

The implementation correctly maps Database::VAR_ID to 'bigint', which is suitable for ID fields in PostgreSQL. This change aligns with the broader enhancement introducing explicit support for ID and sequence attribute types across the database system.

tests/e2e/Adapter/Scopes/CollectionTests.php (2)

110-118: LGTM! Appropriate attribute definition for VAR_ID type.

The new attribute definition correctly uses:

  • Size 0 (appropriate for ID types)
  • Not signed (false, correct for IDs)
  • Not required (reasonable default)
  • Not an array

158-158: LGTM! Assertions properly updated for the new attribute and index.

The test correctly:

  • Updates counts from 3 to 4 for both attributes and indexes
  • Verifies the new attribute4 has the correct ID and VAR_ID type
  • Verifies the new index4 has the correct ID and INDEX_KEY type

Also applies to: 165-166, 169-169, 176-177

tests/e2e/Adapter/Scopes/AttributeTests.php (1)

74-116: Test coverage for VAR_ID attribute looks comprehensive.

The test properly covers creation, indexing, and deletion of the new VAR_ID attribute type. The assertion counts have been correctly adjusted to account for the additional attribute.

src/Database/Validator/Structure.php (1)

35-36: Sequence validation implementation looks correct.

The changes properly integrate the new VAR_SEQUENCE and VAR_ID types with the Sequence validator, correctly using the injected idAttributeType parameter.

Also applies to: 319-326

tests/e2e/Adapter/Scopes/DocumentTests.php (6)

42-42: LGTM: VAR_ID attribute creation is correctly implemented.

The test properly creates a VAR_ID attribute with appropriate parameters (size=0, required=false), which aligns with the expected behavior for ID-type attributes.


70-70: Excellent test coverage for VAR_ID attribute value handling.

The test correctly sets an ID value as a string and validates both the data type (string) and the exact value. This provides good coverage for the VAR_ID functionality.

Also applies to: 94-95


150-150: Good edge case testing for unset ID attribute.

This assertion correctly verifies that when creating a document with manual sequence but no explicit id attribute, the attribute value is null. This tests the expected default behavior.


215-235: Comprehensive validation testing for invalid sequence values.

The test correctly validates that setting $sequence to '0' triggers appropriate validation errors. The exception type and message verification ensure the VAR_SEQUENCE validation is working as expected.


237-268: Thorough testing of null ID values across operations.

This test segment excellently covers:

  • Document creation with null id attribute
  • Retrieval verification after creation
  • Database fetch verification
  • Query operations using isNull

The test ensures null values are properly handled throughout the document lifecycle.


269-302: Excellent edge case coverage for '0' string values.

This test properly validates that the string '0' is treated as a valid ID value (not confused with falsy values). The comprehensive testing includes:

  • Creation with '0' string value
  • Type verification (string)
  • Value verification
  • Retrieval operations
  • Query operations with equal condition

This is particularly important for edge case handling in ID validation.

src/Database/Database.php (4)

43-44: LGTM!

The new attribute type constants follow the existing naming convention and are appropriately placed.


171-172: LGTM!

The change to use VAR_SEQUENCE type with size 0 is appropriate for the $sequence attribute as sequences don't require size constraints.


3652-3657: LGTM!

The Structure validator instantiation correctly includes the adapter's ID attribute type, enabling adapter-specific ID validation. This pattern is consistently applied across all Structure validator instantiations in the file.


1792-1794: Skip validation for VAR_ID/VAR_SEQUENCE in validateAttribute

The empty case self::VAR_ID: and absence of VAR_SEQUENCE are intentional—this method only enforces size/format rules on user‐defined types (string, integer, etc.). Both id and sequence attributes are managed by the adapter and other validators (e.g. in Structure.php) rather than here. No changes are needed.

Likely an incorrect or invalid review comment.

Copy link
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: 0

🧹 Nitpick comments (1)
tests/unit/Validator/StructureTest.php (1)

655-724: Remove redundant test case for MongoDB ID validation.

The testId() method correctly tests ID validation for different database types, but contains a redundant test case for MongoDB validation.

Apply this diff to remove the duplicate test:

-        $this->assertEquals(true, $validator->isValid(new Document([
-            '$collection' => ID::custom('posts'),
-            'title' => 'My Title',
-            'description' => null,
-            'rating' => 5,
-            'price' => 1.99,
-            'published' => true,
-            'tags' => ['dog', 'cat', 'mouse'],
-            'feedback' => 'team@appwrite.io',
-            'id' => $mongoid,
-        ])));

The first MongoDB validation test (lines 701-711) already covers this scenario adequately.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between fd1b288 and 549323a.

📒 Files selected for processing (9)
  • src/Database/Adapter/SQL.php (2 hunks)
  • src/Database/Database.php (13 hunks)
  • src/Database/Validator/Sequence.php (1 hunks)
  • tests/unit/Validator/DocumentsQueriesTest.php (4 hunks)
  • tests/unit/Validator/IndexedQueriesTest.php (3 hunks)
  • tests/unit/Validator/QueriesTest.php (1 hunks)
  • tests/unit/Validator/Query/FilterTest.php (1 hunks)
  • tests/unit/Validator/QueryTest.php (10 hunks)
  • tests/unit/Validator/StructureTest.php (23 hunks)
🚧 Files skipped from review as they are similar to previous changes (8)
  • tests/unit/Validator/QueriesTest.php
  • tests/unit/Validator/DocumentsQueriesTest.php
  • src/Database/Adapter/SQL.php
  • tests/unit/Validator/QueryTest.php
  • tests/unit/Validator/IndexedQueriesTest.php
  • tests/unit/Validator/Query/FilterTest.php
  • src/Database/Validator/Sequence.php
  • src/Database/Database.php
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/unit/Validator/StructureTest.php (4)
src/Database/Database.php (1)
  • Database (35-6809)
src/Database/Validator/Structure.php (2)
  • Structure (18-429)
  • isValid (207-241)
src/Database/Document.php (1)
  • Document (12-460)
src/Database/Validator/Sequence.php (1)
  • isValid (39-68)
⏰ 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). (11)
  • GitHub Check: Adapter Tests (SharedTables/MariaDB)
  • GitHub Check: Adapter Tests (SharedTables/Postgres)
  • GitHub Check: Adapter Tests (SharedTables/MySQL)
  • GitHub Check: Adapter Tests (SharedTables/SQLite)
  • GitHub Check: Adapter Tests (SQLite)
  • GitHub Check: Adapter Tests (Postgres)
  • GitHub Check: Adapter Tests (MariaDB)
  • GitHub Check: Adapter Tests (Pool)
  • GitHub Check: Adapter Tests (MySQL)
  • GitHub Check: Adapter Tests (Mirror)
  • GitHub Check: Unit Test
🔇 Additional comments (3)
tests/unit/Validator/StructureTest.php (3)

93-102: LGTM: ID attribute definition is properly configured.

The new id attribute definition correctly uses Database::VAR_ID type and appropriate default values for a non-required ID field.


134-137: LGTM: Structure constructor calls updated consistently.

All Structure validator instantiations have been systematically updated to include the Database::VAR_ID_INT parameter, ensuring consistent behavior across all test methods.

Also applies to: 149-152, 161-164, 182-185, 202-205, 233-236, 255-258, 276-279, 295-298, 316-319, 377-380, 396-399, 415-418, 449-452, 507-510, 541-544, 575-578, 596-599, 617-620, 638-641, 657-660


216-216: LGTM: ID field added to test document.

The addition of 'id' => '1000' to the test document is appropriate for testing ID validation with the new attribute type.

Copy link
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07ab3f3 and 9961ba2.

📒 Files selected for processing (7)
  • src/Database/Adapter/MariaDB.php (1 hunks)
  • src/Database/Adapter/Postgres.php (1 hunks)
  • src/Database/Adapter/SQL.php (2 hunks)
  • src/Database/Database.php (15 hunks)
  • src/Database/Validator/Structure.php (4 hunks)
  • tests/e2e/Adapter/Scopes/DocumentTests.php (5 hunks)
  • tests/unit/Validator/StructureTest.php (23 hunks)
🚧 Files skipped from review as they are similar to previous changes (6)
  • src/Database/Adapter/SQL.php
  • src/Database/Adapter/Postgres.php
  • src/Database/Validator/Structure.php
  • src/Database/Adapter/MariaDB.php
  • src/Database/Database.php
  • tests/e2e/Adapter/Scopes/DocumentTests.php
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: in partialstructure validator, when filtering for required attributes validation using the $required...
Learnt from: ArnabChatterjee20k
PR: utopia-php/database#642
File: src/Database/Validator/PartialStructure.php:43-52
Timestamp: 2025-07-30T19:17:53.630Z
Learning: In PartialStructure validator, when filtering for required attributes validation using the $requiredAttributes parameter, $this->attributes should be used instead of the merged $attributes array because this validation is specifically for internal attributes like $createdAt and $updatedAt that are defined in the base Structure class, not collection-specific attributes.

Applied to files:

  • tests/unit/Validator/StructureTest.php
🧬 Code Graph Analysis (1)
tests/unit/Validator/StructureTest.php (3)
src/Database/Database.php (1)
  • Database (36-6880)
src/Database/Validator/Structure.php (2)
  • Structure (18-425)
  • isValid (207-241)
tests/unit/DocumentTest.php (1)
  • testId (89-93)
⏰ 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). (1)
  • GitHub Check: Setup & Build Docker Image
🔇 Additional comments (3)
tests/unit/Validator/StructureTest.php (3)

93-102: LGTM! New VAR_ID attribute definition added correctly.

The new id attribute with type Database::VAR_ID is properly configured for testing the new ID attribute type functionality. The attribute settings (non-required, unsigned, non-array) are appropriate for ID fields.


134-137: LGTM! Structure constructor calls updated correctly.

All test methods have been consistently updated to include the new Database::VAR_ID_INT parameter in the Structure constructor, reflecting the updated constructor signature that now requires an ID attribute type parameter.

Also applies to: 149-152, 161-164, 184-187, 206-209, 241-244, 265-268, 288-291, 309-312, 332-335, 401-404, 422-425, 443-446, 481-484, 547-550, 585-588, 623-626, 646-649, 669-672, 692-695


221-223: LGTM! ID field test case added appropriately.

The addition of the id field with value '1000' in the test document properly exercises the new VAR_ID attribute validation functionality.

@fogelito fogelito requested a review from abnegate July 31, 2025 14:16
@utopia-php utopia-php deleted a comment from coderabbitai bot Aug 3, 2025
@abnegate abnegate merged commit e021d48 into main Aug 4, 2025
15 checks passed
@abnegate abnegate deleted the primary-attribute branch August 4, 2025 09:35
@coderabbitai coderabbitai bot mentioned this pull request Aug 6, 2025
This was referenced Oct 1, 2025
This was referenced Oct 17, 2025
@coderabbitai coderabbitai bot mentioned this pull request Nov 23, 2025
@coderabbitai coderabbitai bot mentioned this pull request Dec 31, 2025
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.

3 participants