Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented Jul 31, 2025

Summary by CodeRabbit

  • New Features

    • Enhanced JSON field retrieval functions to support both string keys and integer indices, enabling access to JSON object properties and array elements.
  • Bug Fixes

    • Improved parsing logic for JSON field functions to ensure compatibility with various Doctrine ORM versions.
  • Tests

    • Expanded test coverage with new unit and integration tests covering JSON extraction by key, array index, nested access, null values, and non-existent fields for thorough validation.

@coderabbitai
Copy link

coderabbitai bot commented Jul 31, 2025

Walkthrough

The changes update the JSON field extraction functions and their tests to support both string keys and integer indices, aligning with PostgreSQL's JSON operators. Parsing logic in the core classes is enhanced, inheritance hierarchies are adjusted, and test coverage is expanded with cases for array indices and nested JSON access.

Changes

Cohort / File(s) Change Summary
Core JSON Field Function Parsing
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php
Refactored parsing logic to support both string keys and integer indices for JSON field access; introduced feedParserWithNodes and removed fixed node mappings; adapted for different Doctrine ORM versions.
Integer JSON Field Extraction
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsInteger.php
Changed parent class from BaseFunction to JsonGetField; removed explicit node mappings; updated docblock to clarify support for both string and integer keys.
Text JSON Field Extraction
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsText.php
Changed parent class from BaseFunction to JsonGetField; removed explicit node mappings; updated docblock and usage examples for both key types.
Integer Extraction Unit Tests
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php
Added test cases for array indices and nested extraction; registered JSON_GET_FIELD for testing; expanded expected SQL/DQL scenarios and descriptions.
Text Extraction Unit Tests
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php
Added JsonGetField to registered functions; expanded tests to cover array indices, nested extraction, and more scenarios; labeled test cases for clarity.
Core JSON Field Unit Tests
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php
Added new test cases for array index extraction and nested field access; expanded SQL/DQL coverage for numeric and string keys.
Integer Extraction Integration Tests
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php
Added JsonGetField to registered functions; added new test for integer extraction by array index; renamed a test method for clarity.
Text Extraction Integration Tests
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php
New integration test class added; tests JSON extraction as text by property name, index, nested access, null values, and non-existent indices.
Core JSON Field Integration Tests
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php
New integration test class added; covers JSON property access by name, array index, nested access, empty arrays, and non-existent fields or indices.

Sequence Diagram(s)

sequenceDiagram
    participant DQL_User as DQL User
    participant Doctrine as Doctrine ORM
    participant JsonGetField as JsonGetField Function
    participant Database as PostgreSQL

    DQL_User->>Doctrine: Use JSON_GET_FIELD(column, key_or_index)
    Doctrine->>JsonGetField: Parse function call
    JsonGetField->>JsonGetField: Parse first arg as StringPrimary (column)
    JsonGetField->>JsonGetField: Try parse second arg as ArithmeticPrimary (index)
    alt If fails
        JsonGetField->>JsonGetField: Parse second arg as StringPrimary (key)
    end
    JsonGetField->>Doctrine: Return parsed AST
    Doctrine->>Database: Generate SQL with -> or ->> operator
    Database-->>Doctrine: Return result
    Doctrine-->>DQL_User: Return extracted value
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~18 minutes

Poem

In fields of JSON, keys and indices play,
Now rabbits can hop both string and integer way.
With parsing improved and tests that abound,
Nested arrays and objects are easily found.
PostgreSQL smiles, the queries run true—
A carrot for each, and a function anew! 🥕

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 9e70791 and 8cbd460.

📒 Files selected for processing (4)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (2 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (3 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php
🧰 Additional context used
🧠 Learnings (4)
📓 Common learnings
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the `RIGHT_EXISTS_ON_LEFT` DQL function, which maps to PostgreSQL's `?` operator. This is used for checking if a specific value exists in a JSONB array column.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php:10-0
Timestamp: 2025-03-13T15:04:55.052Z
Learning: The implementation of JSON_EXISTS in this library supports only the basic form with two parameters (target_json, path_text) and doesn't support additional features like strict mode (third boolean parameter), ON ERROR clause, or other advanced PostgreSQL JSON_EXISTS capabilities due to DQL limitations.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#366
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayPositionsTest.php:1-36
Timestamp: 2025-05-03T00:18:09.078Z
Learning: Always check the current official PostgreSQL documentation at https://www.postgresql.org/docs/ to verify function signatures and behaviors before suggesting improvements or additional tests. The `array_positions` function specifically has a fixed signature with exactly two parameters (array and search value), while `array_position` is variadic with 2-3 parameters.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#366
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayPositionsTest.php:1-36
Timestamp: 2025-05-03T00:18:09.078Z
Learning: Always check the current official PostgreSQL documentation at https://www.postgresql.org/docs/ to verify function signatures and behaviors before suggesting improvements or additional tests. The `array_positions` function specifically has a fixed signature with exactly two parameters (array and search value), while `array_position` is variadic with 2-3 parameters.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#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.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#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
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-26T02:46:12.804Z
Learning: The PR "preserve the type of floats and integers when transforming back and forth between PostgreSQL and PHP" improves type handling by ensuring that integers remain integers, floats remain floats, numeric strings stay as strings, and booleans are properly converted through the transformation process.
Learnt from: karpilin
PR: martin-georgiev/postgresql-for-doctrine#386
File: tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTimestampTest.php:34-39
Timestamp: 2025-05-27T16:10:35.054Z
Learning: When reviewing PostgreSQL formatting function tests, the error handling behavior should match PostgreSQL's actual implementation rather than assuming consistency across all formatting functions, as different functions may handle invalid inputs differently.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (8)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (8)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (9)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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
PR: #352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

🧬 Code Graph Analysis (1)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (5)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (1)
  • JsonGetField (25-50)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php (1)
  • JsonTestCase (9-56)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (1)
  • getStringFunctions (12-18)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (1)
  • getStringFunctions (12-18)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (248-262)
⏰ 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). (20)
  • GitHub Check: PostgreSQL 17 + PHP 8.4
  • GitHub Check: PostgreSQL 17 + PHP 8.3
  • GitHub Check: PostgreSQL 16 + PHP 8.2
  • GitHub Check: PostgreSQL 16 + PHP 8.1
  • GitHub Check: PostgreSQL 17 + PHP 8.1
  • GitHub Check: PostgreSQL 16 + PHP 8.4
  • GitHub Check: PostgreSQL 16 + PHP 8.3
  • GitHub Check: PostgreSQL 17 + PHP 8.2
  • GitHub Check: sloth
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 1.2
  • GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer latest
🔇 Additional comments (5)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (3)

7-7: Good addition to support nested JSON extraction.

Adding the JsonGetField import and registration enables nested JSON access patterns, which is essential for the new index-based functionality demonstrated in the test cases.

Also applies to: 15-15


27-37: Excellent test coverage for index-based JSON extraction.

This test properly validates the new index support by:

  • Setting up appropriate test data with a numeric array
  • Demonstrating nested function usage with both string keys and integer indices
  • Verifying correct integer extraction from array elements

The test approach aligns well with the PR objective to improve JSON field extraction with index support.


53-53: Good naming improvement for clarity.

Renaming the method to test_json_get_field_as_integer_nonexistent_property_name provides better specificity and distinguishes it from potential future tests for non-existent indices.

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

1-54: Comprehensive integration test coverage for JsonGetFieldAsText.

This new test file provides excellent coverage of the enhanced JSON field extraction functionality:

  • Function registration: Properly registers both JSON_GET_FIELD and JSON_GET_FIELD_AS_TEXT to enable nested access patterns
  • Core scenarios: Tests both string key access ('name') and integer index access (0)
  • Nested access: Validates complex nested JSON extraction patterns
  • Edge cases: Properly handles null values and non-existent indices
  • Consistent patterns: Follows established testing conventions in the codebase

The test structure aligns well with the PR objective to improve JSON field extraction by adding index support.

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

1-59: Excellent foundation test coverage for JsonGetField functionality.

This new integration test file provides comprehensive validation of the core JSON_GET_FIELD function with the enhanced parsing capabilities:

Strengths:

  • Complete scenario coverage: Tests string keys, integer indices, nested access, and edge cases
  • Correct return value expectations: Properly expects JSON-formatted strings (e.g., "John", "developer") which aligns with PostgreSQL's -> operator behavior
  • Edge case handling: Appropriately tests empty arrays and non-existent keys/indices, expecting null returns
  • Nested access patterns: Validates complex JSON traversal using chained function calls

Technical accuracy:

  • The expected return values correctly show JSON-formatted strings with quotes, distinguishing this base function from its typed variants (AsText, AsInteger)
  • Test data usage aligns with the JsonTestCase fixture structure
  • Method naming follows consistent conventions

This test file serves as the foundation for validating the enhanced JSON field extraction capabilities introduced in this PR.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bug

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.
    • @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 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.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

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

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

32-47: Consider more specific error handling in the fallback logic.

The parsing approach is sound, but the broad QueryException catch might mask unrelated parsing errors. Consider checking if the exception is specifically about the expected parsing failure.

However, the overall implementation correctly handles both integer indices and string keys with proper version compatibility.

        // Parse second parameter - try ArithmeticPrimary first, then StringPrimary
        try {
            $this->nodes[1] = $parser->ArithmeticPrimary();
-        } catch (QueryException) {
+        } catch (QueryException $e) {
+            // Only fall back to StringPrimary if it's a parsing-related exception
             // If ArithmeticPrimary fails (e.g., when encountering a string), try StringPrimary
             $this->nodes[1] = $parser->StringPrimary();
         }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 1276f8d and 9e70791.

📒 Files selected for processing (6)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (2 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsInteger.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsText.php (1 hunks)
  • tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (1 hunks)
  • tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (1 hunks)
  • tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (2 hunks)
🧰 Additional context used
🧠 Learnings (7)
📓 Common learnings
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the `RIGHT_EXISTS_ON_LEFT` DQL function, which maps to PostgreSQL's `?` operator. This is used for checking if a specific value exists in a JSONB array column.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php:10-0
Timestamp: 2025-03-13T15:04:55.052Z
Learning: The implementation of JSON_EXISTS in this library supports only the basic form with two parameters (target_json, path_text) and doesn't support additional features like strict mode (third boolean parameter), ON ERROR clause, or other advanced PostgreSQL JSON_EXISTS capabilities due to DQL limitations.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#366
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayPositionsTest.php:1-36
Timestamp: 2025-05-03T00:18:09.078Z
Learning: Always check the current official PostgreSQL documentation at https://www.postgresql.org/docs/ to verify function signatures and behaviors before suggesting improvements or additional tests. The `array_positions` function specifically has a fixed signature with exactly two parameters (array and search value), while `array_position` is variadic with 2-3 parameters.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#366
File: tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayPositionsTest.php:1-36
Timestamp: 2025-05-03T00:18:09.078Z
Learning: Always check the current official PostgreSQL documentation at https://www.postgresql.org/docs/ to verify function signatures and behaviors before suggesting improvements or additional tests. The `array_positions` function specifically has a fixed signature with exactly two parameters (array and search value), while `array_position` is variadic with 2-3 parameters.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#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.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#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
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-26T02:46:12.804Z
Learning: The PR "preserve the type of floats and integers when transforming back and forth between PostgreSQL and PHP" improves type handling by ensuring that integers remain integers, floats remain floats, numeric strings stay as strings, and booleans are properly converted through the transformation process.
Learnt from: karpilin
PR: martin-georgiev/postgresql-for-doctrine#386
File: tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTimestampTest.php:34-39
Timestamp: 2025-05-27T16:10:35.054Z
Learning: When reviewing PostgreSQL formatting function tests, the error handling behavior should match PostgreSQL's actual implementation rather than assuming consistency across all formatting functions, as different functions may handle invalid inputs differently.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (9)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

Learnt from: martin-georgiev
PR: #352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (10)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

Learnt from: martin-georgiev
PR: #352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
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
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php:10-0
Timestamp: 2025-03-13T15:04:55.052Z
Learning: The implementation of JSON_EXISTS in this library supports only the basic form with two parameters (target_json, path_text) and doesn't support additional features like strict mode (third boolean parameter), ON ERROR clause, or other advanced PostgreSQL JSON_EXISTS capabilities due to DQL limitations.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsInteger.php (8)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-26T02:46:12.804Z
Learning: The PR "preserve the type of floats and integers when transforming back and forth between PostgreSQL and PHP" improves type handling by ensuring that integers remain integers, floats remain floats, numeric strings stay as strings, and booleans are properly converted through the transformation process.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (10)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
PR: #352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

Learnt from: martin-georgiev
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
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php:10-0
Timestamp: 2025-03-13T15:04:55.052Z
Learning: The implementation of JSON_EXISTS in this library supports only the basic form with two parameters (target_json, path_text) and doesn't support additional features like strict mode (third boolean parameter), ON ERROR clause, or other advanced PostgreSQL JSON_EXISTS capabilities due to DQL limitations.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (12)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
PR: #350
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php:78-88
Timestamp: 2025-04-18T10:33:52.412Z
Learning: In SQL generation code for the postgresql-for-doctrine library, it's better to fail explicitly with clear errors than to use fallback behavior that makes assumptions about node types, as this could lead to functional bugs or security issues.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
PR: #352
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RegexpInstrTest.php:1-67
Timestamp: 2025-04-20T11:24:18.300Z
Learning: This PostgreSQL-for-Doctrine project is a translation layer only, focusing on correctly converting Doctrine DQL to PostgreSQL SQL syntax. It ensures arguments are passed in the expected format but does not test or handle PostgreSQL's actual function behavior or data handling. Test cases should focus on DQL-to-SQL translation and argument validation, not on PostgreSQL-specific behaviors.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php:10-0
Timestamp: 2025-03-13T15:04:55.052Z
Learning: The implementation of JSON_EXISTS in this library supports only the basic form with two parameters (target_json, path_text) and doesn't support additional features like strict mode (third boolean parameter), ON ERROR clause, or other advanced PostgreSQL JSON_EXISTS capabilities due to DQL limitations.

Learnt from: martin-georgiev
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
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).

Learnt from: martin-georgiev
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.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsText.php (10)

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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), not PHPUnit's TestCase, and therefore don't need an explicit import statement.

Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#0
File: :0-0
Timestamp: 2025-03-11T17:02:51.971Z
Learning: The PostgreSQL-for-doctrine library implements the JSON array element existence check using the RIGHT_EXISTS_ON_LEFT DQL function, which maps to PostgreSQL's ? operator. This is used for checking if a specific value exists in a JSONB array column.

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonValueTest.php:19-35
Timestamp: 2025-03-13T15:00:16.619Z
Learning: The JsonValue implementation in postgres-for-doctrine has documented limitations: it does not support RETURNING type, DEFAULT clause, ON ERROR clause, ON EMPTY clause, and other advanced PostgreSQL JSON_VALUE features due to DQL limitations.

Learnt from: martin-georgiev
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
PR: #350
File: src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php:78-88
Timestamp: 2025-04-18T10:33:52.412Z
Learning: In SQL generation code for the postgresql-for-doctrine library, it's better to fail explicitly with clear errors than to use fallback behavior that makes assumptions about node types, as this could lead to functional bugs or security issues.

Learnt from: martin-georgiev
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.

Learnt from: martin-georgiev
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).

Learnt from: martin-georgiev
PR: #277
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonExistsTest.php:10-0
Timestamp: 2025-03-13T15:04:55.052Z
Learning: The implementation of JSON_EXISTS in this library supports only the basic form with two parameters (target_json, path_text) and doesn't support additional features like strict mode (third boolean parameter), ON ERROR clause, or other advanced PostgreSQL JSON_EXISTS capabilities due to DQL limitations.

🧬 Code Graph Analysis (3)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsInteger.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (1)
  • JsonGetField (25-48)
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (3)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (1)
  • JsonGetField (25-48)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsText.php (1)
  • JsonGetFieldAsText (19-25)
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (3)
  • getStringFunctions (12-17)
  • getExpectedSqlStatements (19-28)
  • getDqlStatements (30-39)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsText.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (1)
  • JsonGetField (25-48)
🔇 Additional comments (17)
tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (2)

24-26: Excellent test coverage for array index support.

The new test cases properly validate JSON array element extraction using integer indices. The SQL expectations correctly use the -> operator with numeric indices and demonstrate proper nesting for complex JSON path access.


35-37: DQL statements correctly match the expected SQL output.

The DQL test cases properly demonstrate the enhanced parsing capability with nested JSON_GET_FIELD calls, supporting both integer indices and string keys as expected.

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (3)

8-8: Proper integration of JsonGetField dependency.

The addition of JsonGetField import and registration correctly supports the nested function calls in the test cases, enabling comprehensive testing of the enhanced parsing capability.

Also applies to: 16-16


24-26: SQL expectations correctly implement integer casting with index support.

The test cases properly validate that both string keys and integer indices are supported, with correct SQL generation using the ->> operator and CAST to BIGINT.


33-35: DQL statements demonstrate proper nested function usage.

The test cases correctly show how JSON_GET_FIELD and JSON_GET_FIELD_AS_INTEGER work together to handle complex JSON path expressions with mixed key types.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsText.php (3)

10-13: Clear documentation of enhanced functionality.

The updated docblock effectively communicates that the function now supports both string keys for object property access and integer indices for array element access, with concrete examples showing the expected SQL output.


19-19: Proper inheritance structure for code reuse.

Extending JsonGetField instead of BaseFunction is an excellent refactoring that inherits the enhanced parsing logic for mixed key types while avoiding code duplication.


21-24: Simplified customization method.

The removal of explicit node mapping calls is appropriate since the parent class JsonGetField now handles the parsing logic for both string keys and integer indices through its feedParserWithNodes method.

tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (3)

8-8: Consistent integration pattern across test files.

The addition of JsonGetField import and registration follows the same pattern as other test files, ensuring comprehensive testing of the integrated functionality.

Also applies to: 16-16


24-26: Proper SQL expectations for text extraction with index support.

The test cases correctly validate text extraction using the ->> operator with both string keys and integer indices, including nested JSON path access.


33-35: Well-structured DQL test cases.

The test cases effectively demonstrate nested function usage and mixed key type support, maintaining consistency with the broader test suite pattern.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsInteger.php (3)

10-13: Comprehensive documentation of enhanced capabilities.

The updated docblock clearly explains support for both string keys and integer indices, with concrete examples showing the expected SQL output including the CAST to BIGINT for integer conversion.


19-19: Consistent inheritance structure across JSON functions.

Extending JsonGetField maintains consistency with JsonGetFieldAsText and properly inherits the enhanced parsing logic for mixed key types.


21-24: Appropriate function prototype for integer casting.

The function prototype correctly implements the PostgreSQL pattern for JSON text extraction with integer casting (CAST(%s ->> %s as BIGINT)), while the simplified method relies on parent class parsing.

src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetField.php (3)

7-11: LGTM!

All new imports are properly used in the implementation - Lexer/TokenType for version-compatible comma parsing, Parser for method parameter, QueryException for fallback parsing, and DoctrineOrm for version detection.


16-19: LGTM!

The updated docblock clearly documents the new dual support for string keys and integer indices with helpful examples showing the expected SQL output.


25-47: Excellent architectural improvement!

The shift from static node mappings to dynamic parsing enables flexible JSON field extraction that properly supports both string keys and integer indices, matching PostgreSQL's native -> operator behavior. This foundation allows child classes to inherit the enhanced parsing capabilities.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 31, 2025
@coveralls
Copy link

Coverage Status

coverage: 93.987% (-0.1%) from 94.084%
when pulling 8cbd460 on bug
into 1276f8d on main.

@martin-georgiev martin-georgiev merged commit 8d18b35 into main Jul 31, 2025
54 of 57 checks passed
@martin-georgiev martin-georgiev deleted the bug branch July 31, 2025 08:36
@github-actions github-actions bot mentioned this pull request Jul 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