Skip to content

chore(cysql): add postgresql property index plan regression tests - BED-8505#93

Merged
zinic merged 1 commit into
SpecterOps:mainfrom
zinic:main
May 30, 2026
Merged

chore(cysql): add postgresql property index plan regression tests - BED-8505#93
zinic merged 1 commit into
SpecterOps:mainfrom
zinic:main

Conversation

@zinic
Copy link
Copy Markdown
Contributor

@zinic zinic commented May 30, 2026

Description

Add property index regression tests to cover translation changes that may change query forms where index matching is essential.

Resolves: BED-8505

Type of Change

  • Chore (a change that does not modify the application functionality)
  • Bug fix (a change that fixes an issue)
  • New feature / enhancement (a change that adds new functionality)
  • Refactor (no behaviour change)
  • Test coverage
  • Build / CI / tooling
  • Documentation

Testing

  • Unit tests added / updated
  • Integration tests added / updated
  • Full test suite run (make test_all with CONNECTION_STRING set)

Driver Impact

  • PostgreSQL driver (drivers/pg)
  • Neo4j driver (drivers/neo4j)

Checklist

  • Code is formatted
  • All existing tests pass
  • go.mod / go.sum are up to date if dependencies changed

Summary by CodeRabbit

  • Documentation

    • Clarified CySQL's suffix/substring indexing behavior for CONTAINS, STARTS WITH, and ENDS WITH patterns.
    • Added regression test documentation for PostgreSQL property index validation.
  • Tests

    • Expanded string predicate tests to cover literal patterns with index verification.
    • Added new integration tests validating PostgreSQL query plans utilize configured property indexes.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Warning

Review limit reached

@zinic, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 54 minutes and 35 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 628de4bf-4c15-4447-be6f-c429fcc2ffd5

📥 Commits

Reviewing files that changed from the base of the PR and between 7df86c0 and fe1c744.

📒 Files selected for processing (4)
  • README.md
  • cypher/Cypher Syntax Support.md
  • cypher/models/pgsql/translate/predicate_test.go
  • integration/pgsql_property_index_plan_test.go

Walkthrough

This PR adds comprehensive PostgreSQL property index plan regression testing. Documentation defines the index-match contract; unit tests validate that specific string predicates translate to index-compatible SQL; and a manual integration test verifies query plans actually use configured B-tree and GIN trigram indexes when executing Cypher predicates on node properties.

Changes

PostgreSQL Property Index Plan Testing

Layer / File(s) Summary
Documentation and Index Contract
README.md, cypher/Cypher Syntax Support.md
README documents the manual integration test requirement and invocation; Cypher Syntax Support narrows the index-match contract to literal CONTAINS, STARTS WITH, ENDS WITH lowered to LIKE, explicitly excluding dynamic helper-lowered forms.
Unit Test Assertions for Index-Compatible Translation
cypher/models/pgsql/translate/predicate_test.go
Refactored TestLiteralStringPredicatesKeepLikePatterns into a table-driven test for literal string predicates; added TestStringPropertyEqualityKeepsBTreeIndexableTextLookup to validate that string equality translates to jsonb_typeof guards and B-tree-indexable text lookups without helper functions or coercion.
Integration Test Entry Point and PostgreSQL Setup
integration/pgsql_property_index_plan_test.go
New manual integration test file; TestPostgreSQLPropertyIndexPlans runs B-tree and trigram sub-suites; setupIndexedPostgresDB initializes the indexed Dawgs graph, asserts schema, and registers cleanup.
B-tree Equality Index Testing with Fixtures
integration/pgsql_property_index_plan_test.go
B-tree sub-suite tests CONTAINS and equality predicates on objectid field; fixtures create targeted nodes; analyzeIndexedNodePartition updates planner stats; assertTranslatedPlanUsesIndex verifies plan uses expected index; negative control mutates SQL to confirm index miss.
GIN Trigram Text Search Index Testing
integration/pgsql_property_index_plan_test.go
GIN trigram sub-suite tests STARTS WITH, ENDS WITH, CONTAINS on name field; assertMutatedTranslatedPlanMissesIndex mutates translated SQL and confirms the trigram index is no longer used.
Test Infrastructure: Translation, EXPLAIN, and Plan Inspection
integration/pgsql_property_index_plan_test.go
Helper functions: translateIndexedCypher translates Cypher to SQL; explainWithSeqScanDisabled runs PostgreSQL EXPLAIN; normalizeExplainPlan decodes EXPLAIN JSON; planContainsIndex recursively searches for index names; replaceSQLExpressionOnce mutates SQL for negative tests; formatPlanForFailure formats plans for assertion output.

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested Labels

go

Poem

🐰 A test hops in to check the plans,
Making sure each index spans,
B-trees and trigrams, side by side,
PostgreSQL's query hopes won't hide! 🥕

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: adding PostgreSQL property index plan regression tests, with a reference to the ticket BED-8505.
Description check ✅ Passed The description is substantially complete, addressing the motivation, type of change, testing performed, and driver impact. All major template sections are filled appropriately.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with 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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@zinic zinic merged commit a637b4a into SpecterOps:main May 30, 2026
8 checks passed
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.

2 participants