Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Apr 9, 2025

Summary by CodeRabbit

  • Refactor

    • Enhanced arithmetic expression processing to improve the accuracy and reliability of query evaluations.
  • Tests

    • Expanded and diversified testing scenarios for handling maximum and minimum value functions, ensuring robust performance across varied arithmetic contexts.

@coderabbitai
Copy link

coderabbitai bot commented Apr 9, 2025

Walkthrough

This pull request updates the mapping configuration and test expectations. The commonNodeMapping property in the BaseComparisonFunction class is updated from 'ArithmeticPrimary' to 'SimpleArithmeticExpression'. In addition, the test cases for the GREATEST and LEAST functions have been modified. Their methods now return associative arrays with multiple keys corresponding to different SQL and DQL scenarios, broadening the testing coverage.

Changes

File(s) Change Summary
src/MartinGeorgiev/…/Functions/BaseComparisonFunction.php Updated the commonNodeMapping property value from 'ArithmeticPrimary' to 'SimpleArithmeticExpression'.
tests/MartinGeorgiev/…/Functions/GreatestTest.php
tests/MartinGeorgiev/…/Functions/LeastTest.php
Modified the getExpectedSqlStatements and getDqlStatements methods to return associative arrays with multiple scenario keys instead of single statements.

Possibly related PRs

Poem

Hop, hop, a change so neat,
Mapping altered with a gentle beat.
Tests now dance with scenarios new,
Each SQL and DQL ring crystal true.
I’m a bunny cheerin’—let’s leap into code! 🐰✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • 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 generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

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 resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @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

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

37-41: Well-structured DQL test cases

These DQL statements effectively test the same scenarios as the SQL statements: multiple columns, column with expression, and multiple expressions. This provides good coverage for the fix implemented in BaseComparisonFunction.

Consider adding a test case with different data types, as PostgreSQL's LEAST function can handle comparisons across compatible types (e.g., integers and floats). This would further align with PostgreSQL's documentation.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GreatestTest.php (1)

37-41: Well-structured DQL test cases

These DQL statements effectively test the same scenarios as the SQL statements: multiple columns, column with expression, and multiple expressions. This provides good coverage for the fix implemented in BaseComparisonFunction.

Consider adding a test case with different data types, as PostgreSQL's GREATEST function can handle comparisons across compatible types (e.g., integers and floats). This would further align with PostgreSQL's documentation.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 88dce8e and b423724.

📒 Files selected for processing (3)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GreatestTest.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LeastTest.php (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/**/*.php`: Use the PostgreSQL official documentation to verify that tests include comprehensive use cases and example SQL que...

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/**/*.php: Use the PostgreSQL official documentation to verify that tests include comprehensive use cases and example SQL queries for the tested SQL functions and operators.

  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LeastTest.php
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GreatestTest.php
🧬 Code Graph Analysis (2)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LeastTest.php (2)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GreatestTest.php (1)
  • getDqlStatements (35-42)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php (1)
  • getDqlStatements (92-92)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GreatestTest.php (3)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LeastTest.php (1)
  • getDqlStatements (35-42)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayCatTest.php (1)
  • getDqlStatements (27-33)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TestCase.php (1)
  • getDqlStatements (92-92)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: sloth
🔇 Additional comments (3)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)

14-14: Appropriate mapping change to prevent infinite parsing loop

Changing from 'ArithmeticPrimary' to 'SimpleArithmeticExpression' is a good choice to avoid the infinite parsing loop mentioned in the PR title. This new mapping should properly handle both simple values and expressions within GREATEST() and LEAST() functions without triggering recursion issues in the parser.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LeastTest.php (1)

28-32: Good test expansion with comprehensive scenarios

The updated test cases properly cover multiple scenarios for the LEAST function, including column references and expressions. This aligns with the PR's goal of fixing parsing issues and matches PostgreSQL's documentation on the LEAST function.

tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GreatestTest.php (1)

28-32: Good test expansion with comprehensive scenarios

The updated test cases properly cover multiple scenarios for the GREATEST function, including column references and expressions. This aligns with the PR's goal of fixing parsing issues and matches PostgreSQL's documentation on the GREATEST function.

@martin-georgiev martin-georgiev merged commit bf2f56a into main Apr 9, 2025
47 of 49 checks passed
@martin-georgiev martin-georgiev deleted the issue-87 branch April 9, 2025 23:32
martin-georgiev added a commit that referenced this pull request Apr 11, 2025
@github-actions github-actions bot mentioned this pull request Apr 11, 2025
@martin-georgiev martin-georgiev changed the title bug: avoid infinite parsing loop for GREATEST() and LEAST() by using SimpleArithmeticExpression fix: avoid infinite parsing loop for GREATEST() and LEAST() by using SimpleArithmeticExpression Apr 11, 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.

2 participants