Skip to content

Conversation

@martin-georgiev
Copy link
Owner

@martin-georgiev martin-georgiev commented May 21, 2025

Summary by CodeRabbit

  • New Features
    • Added integration tests for a wide range of JSONB query functions, including insertion, aggregation, object key extraction, path queries, pretty-printing, value setting, and null value stripping.
  • Tests
    • Expanded test coverage with new test classes and detailed scenarios validating JSONB operations.
    • Enhanced test data with additional JSON objects for broader validation.
    • Renamed and refined existing test methods for clarity and precision.
    • Removed obsolete test methods to maintain test suite relevance.

@martin-georgiev martin-georgiev marked this pull request as ready for review May 21, 2025 17:34
@coveralls
Copy link

coveralls commented May 21, 2025

Coverage Status

coverage: 93.915%. remained the same
when pulling 8b2bdee on integrations3
into b653dce on main.

@coderabbitai
Copy link

coderabbitai bot commented May 21, 2025

Walkthrough

Multiple new integration test classes were introduced to cover various custom Doctrine ORM DQL functions for JSONB operations, including insertion, aggregation, path queries, pretty-printing, key extraction, set operations, and null stripping. Existing tests were updated for improved coverage and accuracy, with some test methods renamed, expanded, or removed. The JSON test data was extended with additional JSON objects for broader test coverage.

Changes

File(s) Change Summary
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php Expanded test data insertion to include three additional JSON objects, increasing total inserted rows from four to ten.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbAggTest.php Renamed a test method for clarity, added a WHERE clause to restrict query results, and removed a test method.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsertTest.php Added new test class JsonbInsertTest with methods to test JSONB insertion at various paths, including error handling for existing paths.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectAggTest.php Added new test class JsonbObjectAggTest to verify aggregation of key-value pairs into JSONB objects.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectKeysTest.php Added new test class JsonbObjectKeysTest to test extraction of keys from JSONB objects.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArrayTest.php Added new test class JsonbPathQueryArrayTest with multiple methods to test JSONB path query array extraction with various filters and inputs.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirstTest.php Added new test class JsonbPathQueryFirstTest with methods to test extraction of the first matching element from JSONB data using path queries.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryTest.php Added new test class JsonbPathQueryTest with methods to test JSONB path query extraction for different scenarios, including arrays and filters.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPrettyTest.php Added new test class JsonbPrettyTest to verify pretty-printing of JSONB data.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetLaxTest.php Added new test class JsonbSetLaxTest with methods to test lax setting of values in JSONB data, covering updates, additions, nested paths, and invalid paths.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetTest.php Added new test class JsonbSetTest with methods to test standard setting of values in JSONB data, including handling of the create_missing flag and nested paths.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbStripNullsTest.php Added new test class JsonbStripNullsTest with methods to test removal of null values from JSONB objects, including verification on specific keys.

Sequence Diagram(s)

sequenceDiagram
    participant TestClass as Integration Test Class
    participant Doctrine as Doctrine ORM
    participant DB as Database

    TestClass->>Doctrine: Register custom DQL JSONB function
    TestClass->>Doctrine: Prepare DQL query with JSONB function
    TestClass->>DB: Execute query
    DB-->>Doctrine: Return query result (JSONB data)
    Doctrine-->>TestClass: Return result
    TestClass->>TestClass: Decode JSON, assert structure/values
Loading

Possibly related PRs

Poem

In the warren of tests, new tunnels appear,
JSONB functions, all tested here!
Paths and pretty, keys and set,
Nulls are stripped with no regret.
Rabbits hop and queries run—
JSON adventures, oh what fun!
🐇✨


📜 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 ec954a5 and 8b2bdee.

📒 Files selected for processing (1)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsertTest.php (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsertTest.php
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: sloth
  • GitHub Check: PHP 8.4 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 1.2
  • GitHub Check: PHP 8.3 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • 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 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: 1

🧹 Nitpick comments (8)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPrettyTest.php (1)

1-26: Well-structured test for the JsonbPretty function.

This new test class follows the established pattern for testing JSON functions. It properly registers the function, constructs an appropriate test query, and verifies the basic functionality by checking the return type.

Consider enhancing this test by also verifying the format of the prettified JSON, not just that it returns a string:

 $result = $this->executeDqlQuery($dql);
 $this->assertIsString($result[0]['result']);
+$this->assertStringContainsString('\n', $result[0]['result'], 'Pretty JSON should contain newlines');
+$this->assertStringContainsString('  ', $result[0]['result'], 'Pretty JSON should contain indentation');
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectKeysTest.php (1)

1-26: Well-structured test class for JsonbObjectKeys function.

This test follows the established pattern for JSON function tests and verifies the basic functionality. However, the assertion only checks that the result is a string but doesn't validate the actual keys extracted.

Consider enhancing the test with more specific assertions:

 $result = $this->executeDqlQuery($dql);
 $this->assertIsString($result[0]['result']);
+// Decode the result string which should be a JSON array of keys
+$keys = json_decode($result[0]['result'], true);
+$this->assertIsArray($keys);
+$this->assertContains('name', $keys);
+$this->assertContains('age', $keys);
+$this->assertContains('tags', $keys);
+$this->assertContains('address', $keys);

This would provide stronger verification that the function is returning the expected object keys.

tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbStripNullsTest.php (2)

27-36: String assertions could be more robust

While the current approach works, string comparison with assertStringNotContainsString to verify null values are removed is potentially brittle, as it depends on specific JSON formatting.

Consider decoding the JSON string first and then asserting on the structure:

- $this->assertStringNotContainsString('"age": null', $result[0]['result']);
- $this->assertStringNotContainsString('"zip": null', $result[0]['result']);
+ $decoded = \json_decode($result[0]['result'], true);
+ $this->assertIsArray($decoded);
+ $this->assertArrayHasKey('name', $decoded);
+ $this->assertArrayNotHasKey('age', $decoded) || $this->assertNotNull($decoded['age']);
+ $this->assertArrayNotHasKey('zip', $decoded['address']) || $this->assertNotNull($decoded['address']['zip']);

18-25: Consider adding assertions for the first test case

The first test only asserts that the result is a string but doesn't verify the actual content.

Consider adding assertions to verify the content of the result, similar to the second test case:

 $this->assertIsString($result[0]['result']);
+$decoded = \json_decode($result[0]['result'], true);
+$this->assertIsArray($decoded);
+$this->assertSame('John', $decoded['name']);
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetTest.php (1)

80-80: Minor inconsistency in assertion style

There's an inconsistency in assertion style between self::assertArrayNotHasKey here and $this->assert* used in the rest of the tests. For consistency, consider using the same style throughout.

-        self::assertArrayNotHasKey('nonexistent', $decoded);
+        $this->assertArrayNotHasKey('nonexistent', $decoded);
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetLaxTest.php (2)

80-80: Minor inconsistency in assertion style

There's an inconsistency in assertion style between self::assertArrayNotHasKey here and $this->assert* used in the rest of the tests. For consistency, consider using the same style throughout.

-        self::assertArrayNotHasKey('invalid', $decoded);
+        $this->assertArrayNotHasKey('invalid', $decoded);

68-81: Consider adding a comment explaining the difference between JSONB_SET and JSONB_SET_LAX

It would be helpful to add a brief comment explaining that the key difference between JSONB_SET and JSONB_SET_LAX is how they handle invalid paths - the LAX variant doesn't throw errors but silently ignores invalid paths.

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

55-63: Consider enhancing exception assertions

The test correctly expects an exception when inserting at an existing path, but it doesn't verify the specific error message or code. This would make the test more robust against changes in exception types while preserving the expected behavior.

         $this->expectException(Exception::class);
+        $this->expectExceptionMessage('path exists'); // Add the expected error message
         $dql = 'SELECT JSONB_INSERT(t.object1, :path, :value) as result 
                 FROM Fixtures\MartinGeorgiev\Doctrine\Entity\ContainsJsons t 
                 WHERE t.id = 1';
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b653dce and 0924b26.

📒 Files selected for processing (12)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbAggTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsertTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectAggTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectKeysTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArrayTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirstTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPrettyTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetLaxTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetTest.php (1 hunks)
  • tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbStripNullsTest.php (1 hunks)
🧰 Additional context used
🧠 Learnings (2)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArrayTest.php (2)
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), rather than PHPUnit's TestCase, and therefore don't need an explicit import.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), not PHPUnit's TestCase, and therefore don't need an explicit import statement.
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryTest.php (2)
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), rather than PHPUnit's TestCase, and therefore don't need an explicit import.
Learnt from: martin-georgiev
PR: martin-georgiev/postgresql-for-doctrine#318
File: tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/XmlAggTest.php:1-9
Timestamp: 2025-03-29T03:31:17.114Z
Learning: Tests in the `Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions` namespace extend a custom `TestCase` class from the same namespace (`Tests\MartinGeorgiev\Doctrine\ORM\Query\AST\Functions\TestCase`), not PHPUnit's TestCase, and therefore don't need an explicit import statement.
🧬 Code Graph Analysis (3)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectKeysTest.php (5)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbObjectKeys.php (1)
  • JsonbObjectKeys (15-22)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php (1)
  • JsonTestCase (9-56)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbAggTest.php (1)
  • getStringFunctions (11-14)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSetTest.php (1)
  • getStringFunctions (11-16)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (236-250)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArrayTest.php (3)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • JsonbPathQueryArray (22-55)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php (1)
  • JsonTestCase (9-56)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (236-250)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirstTest.php (3)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1)
  • JsonbPathQueryFirst (23-56)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php (1)
  • JsonTestCase (9-56)
tests/Integration/MartinGeorgiev/TestCase.php (1)
  • executeDqlQuery (236-250)
⏰ Context from checks skipped due to timeout of 90000ms (20)
  • GitHub Check: PHP 8.1 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • 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.3 + Doctrine ORM 2.14 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM latest + Doctrine Lexer latest
  • GitHub Check: PHP 8.3 + Doctrine ORM 3.0 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.2 + Doctrine ORM 3.0 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 3.0
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: sloth
🔇 Additional comments (17)
tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonTestCase.php (2)

42-44: Good addition of diverse test data structures.

The expanded test data includes important edge cases that will help verify PostgreSQL JSONB functions: empty arrays, empty objects, and null values. This provides more comprehensive test coverage.


49-52: Properly updated SQL insert statement.

The SQL statement has been correctly updated to insert all five JSON objects, maintaining the pattern of duplicating each object in both columns.

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

34-38: Method renamed and query refined for better specificity.

The test method has been appropriately renamed from test_jsonb_agg_with_all_rows to test_jsonb_agg_with_multiple_rows to more accurately reflect its purpose. The query now filters to specific rows rather than selecting all rows, which is a better testing practice as it makes the test more deterministic.

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

1-29: Implementation looks good!

The test correctly validates that JSONB_OBJECT_AGG function works as expected, creating a JSON object from key-value pairs and properly returning it as a string that can be decoded back to an array matching the expected structure.

tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArrayTest.php (4)

18-32: Well-structured test for simple path query

The test correctly validates extraction of a single value using a JSON path expression.


34-48: Good test for array extraction

This test effectively verifies that the function can extract multiple values from a JSON array.


50-65: Comprehensive test for filtered path queries

The test thoroughly validates that path filtering with conditions works correctly by checking both the count and the exact content of the returned array.


67-78: Good validation of column reference usage

This test properly verifies that the function works when referencing a database column instead of a literal JSON string.

tests/Integration/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirstTest.php (5)

18-29: Well-structured test for simple path query

The test correctly validates extraction of a single value using a JSON path expression.


31-42: Good test for array first element extraction

This test effectively verifies that the function returns only the first element when multiple matches exist.


44-55: Thorough test for filtered path queries

The test properly validates that filtering works and returns the correct first matching element.


57-67: Good edge case testing for no matches

This test correctly verifies the behavior when no elements match the path query, ensuring the function returns null as expected.


69-77: Good validation of column reference usage

This test properly verifies that the function works when referencing a database column instead of a literal JSON string.

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

1-82: Good test coverage for the JSONB_SET function!

The tests cover all the essential functionality including updating existing values, adding new values, handling nested paths, and testing the create_missing flag.

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

1-74: Well-structured tests with good coverage for the JSONB_PATH_QUERY function!

The tests cover a comprehensive range of JSON path query scenarios including simple queries, array queries, filtered queries, and column reference queries. The assertions are thorough and validate both the result structure and content.

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

1-82: Good test coverage for the JSONB_SET_LAX function!

The tests effectively cover the essential scenarios including updating existing values, adding new values, handling nested paths, and importantly, testing behavior with invalid paths which is a key differentiator for the LAX variant.

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

1-76: Good test coverage for the JSONB_INSERT function!

The tests cover the essential functionality including inserting new values, handling nested paths, and testing error conditions.

coderabbitai[bot]
coderabbitai bot previously approved these changes May 21, 2025
@martin-georgiev martin-georgiev merged commit 09d479f into main May 21, 2025
54 of 57 checks passed
@martin-georgiev martin-georgiev deleted the integrations3 branch May 21, 2025 18:25
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