Skip to content

Conversation

@martin-georgiev
Copy link
Owner

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

Summary by CodeRabbit

  • Refactor / New Features

    • Enhanced several query functions by replacing fixed mapping definitions with dynamic methods that determine node mapping patterns. This update streamlines and standardizes processing for node mapping across the system.
  • Tests

    • Updated exception handling tests to reflect the revised behavior, ensuring that error responses align with the new implementation approach.

…patterns, thus opening the path to a combination of node types (compared to the previous single type support)
@coveralls
Copy link

Coverage Status

coverage: 95.043% (+0.2%) from 94.87%
when pulling 7052577 on variadic-pattern
into 67265cc on main.

@coderabbitai
Copy link

coderabbitai bot commented Apr 14, 2025

Walkthrough

The changes update multiple Doctrine ORM query AST function classes by replacing the static property commonNodeMapping with a new protected method getNodeMappingPattern() that returns an array of mapping strings. Several classes have this method added, while a few remove the property entirely and adjust internal node processing logic. In addition, a test case has been updated to expect a different exception. Overall, the node mapping mechanism is now encapsulated in a method, with modifications to error handling in functions that iterate over these mapping patterns.

Changes

File(s) Change Summary
src/MartinGeorgiev/.../Functions/Arr.php, .../BaseComparisonFunction.php, .../BaseVariadicFunction.php, .../Row.php, .../ToTsvector.php, .../Unaccent.php Removed property commonNodeMapping and added method getNodeMappingPattern() returning an array with a class-specific mapping string.
src/MartinGeorgiev/.../Functions/ArrayToJson.php, .../DateAdd.php, .../DateSubtract.php, .../JsonBuildObject.php, .../JsonbBuildObject.php, .../JsonbInsert.php, .../JsonbPathExists.php, .../JsonbPathMatch.php, .../JsonbPathQuery.php, .../JsonbPathQueryArray.php, .../JsonbPathQueryFirst.php, .../JsonbSet.php, .../RowToJson.php, .../ToTsquery.php Added protected method getNodeMappingPattern() returning ['StringPrimary'].
tests/MartinGeorgiev/.../BaseComparisonFunctionTestCase.php Updated exception handling: expected exception changed from ParserException to InvalidArgumentForVariadicFunctionException.

Sequence Diagram(s)

sequenceDiagram
    participant Caller as Test/Client
    participant VF as BaseVariadicFunction
    participant Parser as NodeParser

    Caller->>VF: feedParserWithNodes(nodes)
    VF->>VF: getNodeMappingPattern()
    loop For each mapping pattern
        VF->>Parser: feedNode(pattern)
        alt Node accepted
            Parser-->>VF: node added
        else Exception raised
            Parser-->>VF: catch exception
        end
    end
    VF-->>Caller: return updated nodes
Loading

Possibly related PRs

Poem

I'm a hopping rabbit in the code garden so fair,
Mapping nodes anew with a method flair.
Properties retired, methods now bloom bright,
Each function dances in smart delight.
I nibble on patches—swift and neat,
Celebrating changes with a bouncy beat! 🐰


📜 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 67265cc and 7052577.

📒 Files selected for processing (21)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (2 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathExists.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Row.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1 hunks)
  • src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1 hunks)
  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php (2 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/**/*.php`: Use the PostgreSQL official documentation to verify that tests include comprehensive use cases and example SQL que...

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

  • tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php
🧬 Code Graph Analysis (15)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (13)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1)
  • getNodeMappingPattern (19-22)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathExists.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (15)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1)
  • getNodeMappingPattern (19-22)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (6)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (11)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathExists.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (14)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (15)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1)
  • getNodeMappingPattern (19-22)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (13)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1)
  • getNodeMappingPattern (19-22)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Row.php (1)
  • getNodeMappingPattern (17-20)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathExists.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/RowToJson.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
tests/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunctionTestCase.php (1)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Exception/InvalidArgumentForVariadicFunctionException.php (1)
  • InvalidArgumentForVariadicFunctionException (7-46)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Row.php (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (1)
  • getNodeMappingPattern (25-25)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1)
  • getNodeMappingPattern (19-22)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathExists.php (4)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryFirst.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseVariadicFunction.php (16)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/BaseComparisonFunction.php (1)
  • getNodeMappingPattern (14-17)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Arr.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ArrayToJson.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateSubtract.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/DateAdd.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbBuildObject.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbInsert.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQuery.php (1)
  • getNodeMappingPattern (28-31)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathMatch.php (1)
  • getNodeMappingPattern (29-32)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbPathQueryArray.php (1)
  • getNodeMappingPattern (27-30)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/JsonbSet.php (1)
  • getNodeMappingPattern (33-36)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsvector.php (1)
  • getNodeMappingPattern (20-23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Unaccent.php (1)
  • getNodeMappingPattern (19-22)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/Row.php (1)
  • getNodeMappingPattern (17-20)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: PHP 8.4 + Doctrine ORM latest + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.3 + Doctrine ORM 2.18 + Doctrine Lexer 2.1
  • GitHub Check: PHP 8.1 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: PHP 8.2 + Doctrine ORM 2.14 + Doctrine Lexer latest
  • GitHub Check: sloth
🔇 Additional comments (23)
src/MartinGeorgiev/Doctrine/ORM/Query/AST/Functions/ToTsquery.php (1)

20-23: Implementation of abstract method looks good.

The new getNodeMappingPattern() method properly implements the abstract method from BaseVariadicFunction and returns an array with 'StringPrimary' as the pattern. This change aligns with the PR objective to allow for more flexible node mapping patterns in variadic functions.

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

28-31: Implementation of abstract method looks good.

The new getNodeMappingPattern() method correctly implements the abstract method from the parent class and returns the expected 'StringPrimary' pattern in an array. This is consistent with the implementation in other similar classes.

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

29-32: Implementation of abstract method looks good.

The new getNodeMappingPattern() method properly implements the abstract method and returns the 'StringPrimary' pattern in an array. The implementation is consistent with other classes and supports the refactoring goal.

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

27-30: Implementation of abstract method looks good.

The new getNodeMappingPattern() method correctly implements the abstract method from the parent class, returning an array containing 'StringPrimary'. This is consistent with the implementation pattern seen in related classes like JsonbPathQuery, JsonbPathMatch, and others.

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

29-32: Implementation of required abstract method looks good.

The addition of the getNodeMappingPattern() method properly implements the abstract method required by the parent class. This change aligns with the PR objective to allow variadic functions to have different node mapping patterns.

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

28-31: Implementation follows the pattern consistently.

The implementation of getNodeMappingPattern() is consistent with other classes in the codebase, returning ['StringPrimary'] as the expected node type. This supports the refactoring goal of replacing the static property with a method-based approach.

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

28-31: Consistent implementation of required method.

The getNodeMappingPattern() method correctly returns ['StringPrimary'] for this date operation function, matching the pattern established in similar date-related classes like DateAdd.

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

20-23: Implementation matches design pattern for JSON functions.

The getNodeMappingPattern() method implementation returns ['StringPrimary'] which is consistent with other JSON-related functions in the library. This change supports the more flexible node mapping approach being implemented across the codebase.

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

20-23: Implementation of abstract method enhances flexibility in node mapping

The addition of the getNodeMappingPattern() method properly implements the abstract method from BaseVariadicFunction. This change is part of a broader refactoring effort to replace the static property approach with a more flexible method-based implementation, allowing for different node mapping patterns across functions.

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

29-32: Implementation of abstract method enhances flexibility in node mapping

The addition of the getNodeMappingPattern() method properly implements the abstract method from BaseVariadicFunction. This change aligns with the PR objective of allowing variadic functions to have different node mapping patterns, moving from static properties to method-based implementations.

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

28-31: Implementation of abstract method enhances flexibility in node mapping

The addition of the getNodeMappingPattern() method properly implements the abstract method from BaseVariadicFunction. This implementation maintains consistency with other similar classes while enabling more flexible node mapping patterns in the future.

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

28-31: Implementation of abstract method enhances flexibility in node mapping

The addition of the getNodeMappingPattern() method properly implements the abstract method from BaseVariadicFunction. This method-based approach provides better encapsulation and flexibility compared to the previous static property implementation.

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

33-36: Implementation looks good for required abstract method.

The new getNodeMappingPattern() method correctly implements the abstract method from BaseVariadicFunction. Returning 'StringPrimary' as an array element aligns with the implementation pattern used across other similar classes in the codebase.

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

27-30: Implementation looks good for required abstract method.

The new getNodeMappingPattern() method correctly implements the abstract method from BaseVariadicFunction. Returning 'StringPrimary' as an array element is consistent with other implementations in the codebase.

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

17-20: Good implementation with different pattern.

The new getNodeMappingPattern() method correctly implements the abstract method and returns 'InParameter' rather than 'StringPrimary'. This different mapping pattern demonstrates the flexibility of the new approach, allowing specific functions to define their own node types.

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

20-23: Implementation looks good for required abstract method.

The new getNodeMappingPattern() method correctly implements the abstract method from BaseVariadicFunction. Returning 'StringPrimary' as an array element aligns with the implementation pattern used across other similar classes.

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

19-22: Good implementation of the new abstract method.

The implementation correctly returns an array containing the 'StringPrimary' mapping pattern, which matches the previous behavior but follows the new pattern-based approach. This change aligns with the refactoring effort to allow multiple node types in variadic functions.

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

20-23: Appropriate implementation of the abstract method.

The implementation correctly converts the previous string pattern 'StringExpression' into an array return value, maintaining the same functionality while supporting the new architecture that allows multiple pattern types.

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

14-17: Correctly implemented the abstract method in this base class.

The implementation properly returns an array containing 'SimpleArithmeticExpression', maintaining the original functionality while adapting to the new pattern-based approach. This change allows derived comparison functions to inherit this implementation or override it as needed.

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

22-25: Well-defined abstract method with proper return type documentation.

The abstract method declaration includes appropriate PHPDoc that clearly indicates the return type is an array of strings. This provides good guidance for implementations in derived classes.


32-43: Good implementation of pattern fallback mechanism.

The updated method now tries each pattern from the array returned by getNodeMappingPattern() in sequence, continuing to the next pattern if a ParserException occurs. This approach gracefully handles multiple possible node patterns, allowing for more flexible query construction.

The validation of arguments is properly moved outside the pattern-trying loop to ensure it happens regardless of which pattern succeeds.


45-74: Good extraction of the node parsing logic to a separate method.

The extraction of the parsing logic to feedParserWithNodesForNodeMappingPattern improves code organization and readability. The method also properly handles both simple patterns (with a single mapping) and complex patterns (with multiple mappings).

The code correctly calculates the node index based on whether the pattern is simple or complex, ensuring proper mapping selection for each node.

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

12-12: Updated exception handling improves code clarity.

The change from using a general ParserException to the more specific InvalidArgumentForVariadicFunctionException aligns with the PR's goal of refactoring variadic functions. Using a custom exception that's specifically designed for argument validation in variadic functions improves error specificity and makes the code's intent clearer.

Also applies to: 23-23

✨ Finishing Touches
  • 📝 Generate Docstrings

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai plan to trigger planning for file edits and PR creation.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@martin-georgiev martin-georgiev merged commit 6a5ba9e into main Apr 14, 2025
49 of 50 checks passed
@martin-georgiev martin-georgiev deleted the variadic-pattern branch April 14, 2025 00:44
@github-actions github-actions bot mentioned this pull request Apr 13, 2025
seb-jean pushed a commit to seb-jean/postgresql-for-doctrine that referenced this pull request Apr 23, 2025
…patterns, thus opening the path to a combination of node types (compared to the previous single type support) (martin-georgiev#349)
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