Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Oct 22, 2025

Summary by CodeRabbit

  • New Features

    • Added UUID_EXTRACT_TIMESTAMP to extract timestamps from UUID v1/v7
    • Added UUID_EXTRACT_VERSION to extract UUID version numbers
    • TO_NUMBER now supports Roman numeral conversion (RN pattern) on PostgreSQL 18+
  • Documentation

    • Updated function reference to document the two UUID extraction functions and Roman numeral support in TO_NUMBER
  • Tests

    • Added unit and integration tests covering UUID extraction functions and Roman numeral TO_NUMBER behavior

- Remove XDEBUG_MODE from composer scripts to avoid redundancy
- Update workflows to explicitly set XDEBUG_MODE=coverage when coverage is needed
- Use --no-coverage flag when xdebug is not installed to prevent warnings
- This fixes 'No code coverage driver available' warning causing CI failures
- Scrutinizer needs XDEBUG_MODE=coverage to generate coverage reports
- This aligns with the GitHub Actions workflow approach
@coderabbitai
Copy link

coderabbitai bot commented Oct 22, 2025

Warning

Rate limit exceeded

@martin-georgiev has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 1 minutes and 33 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 6af99ff and 452ad1c.

📒 Files selected for processing (2)
  • src/MartinGeorgiev/Doctrine/DBAL/Types/BooleanArray.php (1 hunks)
  • src/MartinGeorgiev/Utils/PHPArrayToPostgresValueTransformer.php (1 hunks)

Walkthrough

Adds two new Doctrine AST functions (UUID_EXTRACT_TIMESTAMP, UUID_EXTRACT_VERSION), documents TO_NUMBER Roman-numeral support (RN pattern, PostgreSQL 18+), updates a ToNumber PHPDoc link, and introduces corresponding unit and integration tests for the new functions and TO_NUMBER behavior.

Changes

Cohort / File(s) Summary
Documentation
docs/AVAILABLE-FUNCTIONS-AND-OPERATORS.md, docs/MATHEMATICAL-FUNCTIONS.md
Added UUID_EXTRACT_TIMESTAMP and UUID_EXTRACT_VERSION to function lists; noted TO_NUMBER Roman-numeral (RN) support and updated formatting docs reference to PostgreSQL 18.x.
ToNumber PHPDoc
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToNumber.php
Updated PHPDoc to mention Roman numeral conversion via RN pattern and updated linked PostgreSQL formatting docs to 18.x.
New AST Function Implementations
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractTimestamp.php, src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersion.php
Added classes extending BaseFunction that set prototypes uuid_extract_timestamp(%s) and uuid_extract_version(%s) and register StringPrimary node mappings.
Integration Tests — ToNumber
tests/Integration/.../ToNumberTest.php
Added tests asserting TO_NUMBER converts Roman numerals (uppercase and lowercase) with PostgreSQL version guards.
Unit Tests — ToNumber
tests/Unit/.../ToNumberTest.php
Updated expected SQL/DQL to include TO_NUMBER(..., 'RN') cases.
Integration Tests — UUID Extract Timestamp
tests/Integration/.../UuidExtractTimestampTest.php
New tests verifying timestamp extraction from UUID v1 and v7 and null for non-timestamped UUIDs; enforces Postgres version and registers function mapping.
Unit Tests — UUID Extract Timestamp
tests/Unit/.../UuidExtractTimestampTest.php
New unit test validating DQL→SQL generation for UUID_EXTRACT_TIMESTAMP(...).
Integration Tests — UUID Extract Version
tests/Integration/.../UuidExtractVersionTest.php
New tests verifying version extraction from UUID v1, v4, and v7; includes Postgres version guard and function registration.
Unit Tests — UUID Extract Version
tests/Unit/.../UuidExtractVersionTest.php
New unit test validating DQL→SQL generation for UUID_EXTRACT_VERSION(...).

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer (DQL)
  participant ORM as Doctrine ORM
  participant AST as AST Function (ToNumber / UuidExtract*)
  participant SQL as SQL Generator
  participant DB as PostgreSQL

  Dev->>ORM: Execute DQL with TO_NUMBER(...,'RN') or UUID_EXTRACT_TIMESTAMP/UUID_EXTRACT_VERSION
  ORM->>AST: Resolve function node and mapping
  AST->>SQL: Emit SQL prototype (to_number(...,'RN') / uuid_extract_timestamp(%s) / uuid_extract_version(%s))
  SQL->>DB: Execute generated SQL
  DB-->>SQL: Return result (converted number | timestamp | version | null)
  SQL-->>ORM: Map SQL result back to DQL
  ORM-->>Dev: Return query result
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 I hop through docs and tests anew,
Two UUIDs I gently view —
One yields the time, one shows the type,
Roman numerals? I read them right.
Hooray for functions—small and true!

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The pull request title "feat: add support for uuid_extract_timestamp and uuid_extract_version" clearly and directly describes the main changes in the changeset. The PR adds two new PostgreSQL functions by introducing corresponding PHP implementation classes, comprehensive unit and integration tests, and documentation updates. The title is specific, naming both functions explicitly, and uses conventional commit formatting. It accurately represents the primary objective without unnecessary noise or vague language, making it easy for team members to understand the essence of the changes when scanning history.

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.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 22, 2025
Copy link

@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/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php (1)

37-59: Valid UUID v4 and v7 test implementations.

Both tests correctly validate version extraction from properly formatted UUID v4 and v7 strings. The test coverage includes the most commonly used UUID versions.

The three test methods follow an identical pattern. Consider using PHPUnit's DataProvider to reduce duplication:

#[Test]
#[DataProvider('uuidVersionProvider')]
public function can_extract_version_from_uuid(string $uuid, int $expectedVersion): void
{
    $dql = "SELECT UUID_EXTRACT_VERSION('$uuid') as result
            FROM Fixtures\MartinGeorgiev\Doctrine\Entity\ContainsNumerics t
            WHERE t.id = 1";

    $result = $this->executeDqlQuery($dql);

    $this->assertEquals($expectedVersion, $result[0]['result']);
}

public static function uuidVersionProvider(): array
{
    return [
        'UUID v1' => ['a0eebc99-9c0b-11d1-b465-00c04fd430c8', 1],
        'UUID v4' => ['550e8400-e29b-41d4-a716-446655440000', 4],
        'UUID v7' => ['018e7e39-9f42-7000-8000-000000000000', 7],
    ];
}
📜 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 54aac54 and 8cb6321.

📒 Files selected for processing (2)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractTimestampTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractTimestampTest.php
🧰 Additional context used
🧠 Learnings (2)
📚 Learning: 2025-05-23T11:11:57.951Z
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#383
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RadiansTest.php:1-9
Timestamp: 2025-05-23T11:11:57.951Z
Learning: Tests in the `Tests\Unit\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\Unit\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), rather than PHPUnit's TestCase directly, and therefore don't need an explicit import.

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php
📚 Learning: 2025-03-29T03:31:17.114Z
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), rather than PHPUnit's TestCase, and therefore don't need an explicit import.

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php
🧬 Code graph analysis (1)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php (4)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersion.php (1)
  • UuidExtractVersion (15-22)
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php (2)
  • UuidExtractVersionTest (10-32)
  • getStringFunctions (12-17)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/NumericTestCase.php (1)
  • NumericTestCase (9-49)
tests/Integration/MartinGeorgiev/TestCase.php (2)
  • requirePostgresVersion (317-344)
  • executeDqlQuery (284-298)
🔇 Additional comments (5)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/UuidExtractVersionTest.php (5)

1-9: LGTM! Clean imports and namespace structure.

The namespace and imports are appropriate for an integration test. The use of PHPUnit's Test attribute is correct for PHPUnit 10.


10-10: Appropriate base class selection.

Extending NumericTestCase is correct since uuid_extract_version returns an integer value, and the base class provides the necessary fixture setup.


12-16: Correct PostgreSQL version requirement.

The version check for PostgreSQL 17.0.0 is accurate, as uuid_extract_version was introduced in PostgreSQL 17.


18-23: Function registration follows established pattern.

The registration of UUID_EXTRACT_VERSION matches the pattern used throughout the codebase for custom DQL functions.


25-35: Valid UUID v1 test implementation.

The test correctly validates extraction of version 1 from a properly formatted UUID v1 string.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 22, 2025
coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 22, 2025
@coveralls
Copy link

Coverage Status

coverage: 95.709% (+0.009%) from 95.7%
when pulling cae582d on pg1718
into 976647b on main.

@martin-georgiev martin-georgiev merged commit 77a513f into main Oct 23, 2025
73 of 74 checks passed
@martin-georgiev martin-georgiev deleted the pg1718 branch October 23, 2025 08:55
@github-actions github-actions bot mentioned this pull request Oct 21, 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