Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Nov 8, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced support for arithmetic expressions as arguments in mathematical query functions including CEIL, ROUND, POWER, EXP, LN, LOG, DEGREES, RADIANS, SIGN, CBRT, and GAMMA.
  • Tests

    • Added comprehensive test coverage for mathematical functions with arithmetic expressions.
    • Introduced new TRUNC function test suite with multiple test scenarios.

@coderabbitai
Copy link

coderabbitai bot commented Nov 8, 2025

Walkthrough

This PR modifies AST node pattern mapping in arithmetic functions from 'ArithmeticPrimary' to 'SimpleArithmeticExpression', enabling these functions to accept arithmetic expressions as direct arguments. It includes comprehensive integration tests validating arithmetic expression support across existing functions and introduces a new TRUNC function test suite. A GitHub Actions workflow interval adjustment is also included.

Changes

Cohort / File(s) Summary
Workflow Configuration
.github/workflows/sloth.yml
Sloth job interval increased from 10 to 15
Core Arithmetic Function Implementations
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseArithmeticFunction.php, Gamma.php, Lgamma.php
Node mapping pattern updated from 'ArithmeticPrimary' to 'SimpleArithmeticExpression' to accept arithmetic expressions as function arguments
Integration Tests - Arithmetic Expression Coverage
tests/Integration/.../CbrtTest.php, CeilTest.php, DegreesTest.php, ExpTest.php, GammaTest.php, LnTest.php, LogTest.php, PowerTest.php, RadiansTest.php, RoundTest.php, SignTest.php, WidthBucketTest.php
New test methods added to validate existing functions with arithmetic expressions; minor formatting adjustments in select methods
Integration Tests - New TRUNC Function
tests/Integration/.../TruncTest.php
New test class with eight test methods covering TRUNC with positive/negative numbers, precision, column values, and arithmetic expressions

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

  • Core logic changes are straightforward (single-line pattern substitutions in three function classes)
  • Test additions follow consistent, repetitive patterns across multiple files
  • TruncTest.php requires slightly more attention as a new, comprehensive test class
  • Verify AST node mapping change doesn't inadvertently affect existing function behavior or break backward compatibility

Possibly related PRs

Poem

🐰 Hops through expressions with glee,
Arithmetic now flows wild and free,
TRUNC joins the fray,
Tests save the day,
Workflows tick on at interval fifteen!

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 title clearly and specifically describes the main change: adding support for arithmetic expressions in mathematical functions, which is the primary focus of all file modifications in this changeset.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue474

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.

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)
.github/workflows/sloth.yml (1)

37-37: Increase interval to accommodate expanded test coverage.

The interval increase from 10 to 15 seconds aligns with the PR's addition of extensive integration tests across numerous mathematical functions. This provides a reasonable buffer for Sloth execution time.

Consider monitoring Sloth execution times in subsequent CI runs to validate whether this interval remains sufficient as the test suite continues to grow. If Sloth consistently times out or takes excessive time, you may need to increase it further or optimize the test suite.

📜 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 fc80e05 and e41b72b.

📒 Files selected for processing (17)
  • .github/workflows/sloth.yml (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseArithmeticFunction.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Gamma.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Lgamma.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CeilTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DegreesTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ExpTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GammaTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RadiansTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/WidthBucketTest.php (1 hunks)
🧰 Additional context used
🧠 Learnings (10)
📓 Common learnings
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 263
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Numrange.php:19-21
Timestamp: 2025-03-11T12:32:10.726Z
Learning: In the postgresql-for-doctrine repository, PostgreSQL range functions have distinct implementations for different data types. The `Numrange` function works with numeric/decimal values and is tested using the `ContainsDecimals` fixture with properties typed as `float`. In contrast, the `Int4range` function works with 32-bit integers and is tested using the `ContainsIntegers` fixture with properties typed as `int`. While the PHP implementations share a similar structure (extending `BaseFunction`), they are semantically different as they handle different PostgreSQL data types.
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 357
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php:28-62
Timestamp: 2025-04-22T00:03:37.733Z
Learning: This project focuses on providing Doctrine ORM interfaces to PostgreSQL functions. Tests should validate correct DQL-to-SQL translation rather than PostgreSQL functionality itself. Test cases should focus on parameter passing and SQL generation, not on testing specific PostgreSQL regex pattern behaviors.
📚 Learning: 2025-05-23T11:24:46.898Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 383
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php:22-24
Timestamp: 2025-05-23T11:24:46.898Z
Learning: The LOG function in PostgreSQL/Doctrine implementation supports both single-argument form (LOG(x) for base 10 logarithm) and two-argument form (LOG(b, x) for logarithm with specified base).

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php
📚 Learning: 2025-05-23T11:11:57.951Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 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/LogTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseArithmeticFunction.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GammaTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/WidthBucketTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ExpTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RadiansTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CeilTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Gamma.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DegreesTest.php
📚 Learning: 2025-03-29T03:31:17.114Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 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/LogTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseArithmeticFunction.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GammaTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/WidthBucketTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ExpTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RadiansTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CeilTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Gamma.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DegreesTest.php
📚 Learning: 2025-09-01T18:48:28.508Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 434
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PostGIS/ST_CrossesTest.php:12-31
Timestamp: 2025-09-01T18:48:28.508Z
Learning: When analyzing unit test files in this codebase, always verify the actual file structure and existing patterns before suggesting changes. The ContainsGeometries fixture exists at ./fixtures/MartinGeorgiev/Doctrine/Entity/ContainsGeometries.php and the PostGIS unit tests use the namespace Tests\Unit\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\PostGIS consistently.

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GammaTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/WidthBucketTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ExpTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RadiansTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CeilTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DegreesTest.php
📚 Learning: 2025-04-22T00:03:37.733Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 357
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpMatchTest.php:28-62
Timestamp: 2025-04-22T00:03:37.733Z
Learning: This project focuses on providing Doctrine ORM interfaces to PostgreSQL functions. Tests should validate correct DQL-to-SQL translation rather than PostgreSQL functionality itself. Test cases should focus on parameter passing and SQL generation, not on testing specific PostgreSQL regex pattern behaviors.

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ExpTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php
📚 Learning: 2025-03-11T12:32:10.726Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 263
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Numrange.php:19-21
Timestamp: 2025-03-11T12:32:10.726Z
Learning: In the postgresql-for-doctrine repository, PostgreSQL range functions have distinct implementations for different data types. The `Numrange` function works with numeric/decimal values and is tested using the `ContainsDecimals` fixture with properties typed as `float`. In contrast, the `Int4range` function works with 32-bit integers and is tested using the `ContainsIntegers` fixture with properties typed as `int`. While the PHP implementations share a similar structure (extending `BaseFunction`), they are semantically different as they handle different PostgreSQL data types.

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/WidthBucketTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php
📚 Learning: 2025-04-11T11:23:44.192Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 340
File: tests/MartinGeorgiev/Doctrine/DBAL/Types/InetArrayTest.php:145-145
Timestamp: 2025-04-11T11:23:44.192Z
Learning: In the PostgreSQL for Doctrine test cases, methods that test database-to-PHP conversions should use `mixed` type for parameter and include non-string test cases in their data providers, following the pattern in classes like InetTest, CidrTest, and MacaddrTest.

Applied to files:

  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php
📚 Learning: 2025-05-13T00:08:41.638Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 371
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Tsrange.php:25-27
Timestamp: 2025-05-13T00:08:41.638Z
Learning: When implementing node mapping patterns in BaseVariadicFunction subclasses, if all parameters should be of the same type, simply return an array with a single string element (e.g., ['StringPrimary']). This approach uses the same type for all parameters while min/max argument counts can be controlled separately.

Applied to files:

  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseArithmeticFunction.php
📚 Learning: 2025-04-18T10:20:44.008Z
Learnt from: martin-georgiev
Repo: martin-georgiev/postgresql-for-doctrine PR: 350
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php:22-26
Timestamp: 2025-04-18T10:20:44.008Z
Learning: The `customizeFunction()` method in `BaseVariadicFunction` should not be marked as final because some child classes like `Arr` need to override it to use different SQL syntax patterns (e.g., square brackets instead of parentheses).

Applied to files:

  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Lgamma.php
🧬 Code graph analysis (15)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php (1)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/SignTest.php (2)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (5)
  • Test (19-27)
  • Test (29-37)
  • Test (39-47)
  • Test (49-57)
  • Test (59-67)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/GammaTest.php (2)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (5)
  • Test (19-27)
  • Test (29-37)
  • Test (39-47)
  • Test (49-57)
  • Test (59-67)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/WidthBucketTest.php (2)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (5)
  • Test (19-27)
  • Test (29-37)
  • Test (39-47)
  • Test (49-57)
  • Test (59-67)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ExpTest.php (2)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php (3)
  • Test (19-25)
  • Test (27-33)
  • Test (35-41)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php (4)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Trunc.php (1)
  • Trunc (15-31)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/NumericTestCase.php (1)
  • NumericTestCase (9-49)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/TruncTest.php (1)
  • TruncTest (10-36)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LnTest.php (2)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/LogTest.php (3)
  • Test (19-25)
  • Test (27-33)
  • Test (35-41)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RadiansTest.php (1)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Lgamma.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseFunction.php (1)
  • addNodeMapping (62-65)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/PowerTest.php (3)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (5)
  • Test (19-27)
  • Test (29-37)
  • Test (39-47)
  • Test (49-57)
  • Test (59-67)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CeilTest.php (4)
  • Test (19-25)
  • Test (27-33)
  • Test (35-41)
  • Test (43-49)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (1)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CeilTest.php (2)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/CbrtTest.php (5)
  • Test (19-27)
  • Test (29-37)
  • Test (39-47)
  • Test (49-57)
  • Test (59-67)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RoundTest.php (1)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Gamma.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseFunction.php (1)
  • addNodeMapping (62-65)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DegreesTest.php (1)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (284-298)
🔇 Additional comments (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Gamma.php (1)

20-20: LGTM! Arithmetic expression support added.

The node mapping change from ArithmeticPrimary to SimpleArithmeticExpression enables the GAMMA function to accept arithmetic expressions as arguments (e.g., GAMMA(t.integer1 / 2)), which aligns with the PR objective.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Lgamma.php (1)

20-20: LGTM! Arithmetic expression support added.

The node mapping change mirrors the Gamma function update, enabling LGAMMA to accept arithmetic expressions as arguments.

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

35-41: LGTM! Comprehensive test coverage for arithmetic expressions.

The new test validates that the LN function correctly handles arithmetic expressions as arguments, following the established test pattern and assertion style.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseArithmeticFunction.php (1)

14-17: LGTM! Core change enabling arithmetic expression support.

This change updates the node mapping pattern from ArithmeticPrimary to SimpleArithmeticExpression, enabling all functions extending BaseArithmeticFunction to accept arithmetic expressions as arguments. The change is backward compatible since SimpleArithmeticExpression includes ArithmeticPrimary.

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

43-49: LGTM! Test validates complex arithmetic expressions.

The new test verifies that the CEIL function correctly handles multi-operation arithmetic expressions (multiplication and division), providing good coverage for the feature.

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

35-41: LGTM! Comprehensive test for multi-parameter function.

The test validates arithmetic expression support in both parameters of the LOG function (base and value), providing thorough coverage for the two-argument form.

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

35-41: LGTM! Excellent coverage for multi-parameter function.

The test validates arithmetic expression support across all four parameters of WIDTH_BUCKET, providing comprehensive coverage for functions with multiple arithmetic arguments.

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

58-67: LGTM! Test validates GAMMA arithmetic expression support.

The new test confirms that the GAMMA function correctly evaluates arithmetic expressions, complementing the node mapping change in the function implementation.

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

39-47: LGTM! Comprehensive arithmetic expression test.

The new test validates SIGN with arithmetic expressions, correctly testing SIGN(n.integer1 - n.integer2) where integer1=10 and integer2=20, resulting in -1. This aligns with the PR objective to support arithmetic expressions in mathematical functions.

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

35-41: LGTM! Arithmetic expression validation for RADIANS.

The test correctly validates RADIANS with an arithmetic expression (n.integer1 * 18 = 180°), expecting π radians. The delta tolerance of 0.0001 is appropriate for floating-point comparison.

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

69-77: LGTM! Tests arithmetic expressions in both arguments.

Excellent test coverage validating POWER with arithmetic expressions in both base and exponent: POWER(n.integer1 + n.integer2, n.integer1 / 5) = POWER(30, 2) = 900. This thoroughly exercises the new SimpleArithmeticExpression support.

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

35-41: LGTM! Validates EXP with division expression.

The test correctly validates EXP with an arithmetic expression (n.integer1 / 10 = 1), expecting Euler's constant. The implementation follows the established pattern from other function tests in this PR.

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

59-67: LGTM! Validates CBRT with complex arithmetic expression.

The test correctly validates CBRT with a multi-operation arithmetic expression (n.integer1 + n.integer2 - 3 = 27), expecting the cube root of 3.0. This demonstrates proper handling of compound expressions.

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

35-41: LGTM! Validates DEGREES with division expression.

The test correctly validates DEGREES with an arithmetic expression combining decimal and integer properties (n.decimal1 / n.integer1 = 1.05 radians ≈ 60.16 degrees). The precision delta is appropriately set.

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

75-103: LGTM! Comprehensive arithmetic expression coverage for ROUND.

Excellent test coverage with three complementary scenarios:

  1. Simple arithmetic expression without precision
  2. Arithmetic expression with precision parameter
  3. Parenthesized expression with precision

All calculations are correct and thoroughly validate the SimpleArithmeticExpression support in ROUND function arguments.

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

1-98: LGTM! Comprehensive integration test suite for TRUNC function.

This new test class provides excellent coverage for the TRUNC function:

  • Basic truncation (positive/negative numbers)
  • Precision parameter support (positive/negative precision)
  • Column value truncation
  • Arithmetic expression support (simple, with precision, parenthesized)

All test calculations are correct, and the implementation follows the established NumericTestCase pattern. The arithmetic expression tests align perfectly with the PR objective of enabling SimpleArithmeticExpression support in mathematical functions.

@martin-georgiev martin-georgiev merged commit 75b025d into main Nov 8, 2025
91 of 92 checks passed
@martin-georgiev martin-georgiev deleted the issue474 branch November 8, 2025 16:36
@github-actions github-actions bot mentioned this pull request Nov 8, 2025
@coveralls
Copy link

Coverage Status

coverage: 95.709%. remained the same
when pulling e41b72b on issue474
into fc80e05 on main.

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