-
-
Notifications
You must be signed in to change notification settings - Fork 56
feat(#401): improve JSON field extraction by adding index support #402
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThe 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
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
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~18 minutes Poem
Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧠 Learnings (4)📓 Common learningstests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (8)Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsIntegerTest.php (8)Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (9)Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev Learnt from: martin-georgiev 🧬 Code Graph Analysis (1)tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldTest.php (5)
⏰ 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)
🔇 Additional comments (5)
✨ Finishing Touches
🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this 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
QueryExceptioncatch 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
📒 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_FIELDcalls, 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
JsonGetFieldimport 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 andCASTtoBIGINT.
33-35: DQL statements demonstrate proper nested function usage.The test cases correctly show how
JSON_GET_FIELDandJSON_GET_FIELD_AS_INTEGERwork 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
JsonGetFieldinstead ofBaseFunctionis 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
JsonGetFieldnow handles the parsing logic for both string keys and integer indices through itsfeedParserWithNodesmethod.tests/Unit/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonGetFieldAsTextTest.php (3)
8-8: Consistent integration pattern across test files.The addition of
JsonGetFieldimport 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
CASTtoBIGINTfor integer conversion.
19-19: Consistent inheritance structure across JSON functions.Extending
JsonGetFieldmaintains consistency withJsonGetFieldAsTextand 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.
Summary by CodeRabbit
New Features
Bug Fixes
Tests