Skip to content

fix(#6428): EXPORT/BACKUP DATABASE and REBUILD INDEX drop their WITH settings when re-rendered to text - #6434

Merged
lvca merged 1 commit into
mainfrom
issue-6428
Aug 19, 2026
Merged

lvca merged 1 commit into
mainfrom
issue-6428

Conversation

@lvca

@lvca lvca commented Aug 18, 2026

Copy link
Copy Markdown
Member

Summary

Fixes #6428.

Issue #6428's item 2 (the node-identity sweep from #6409 isn't exhaustive) is explicitly a marker for next time,
not a request for an audit right now - no code change for it in this PR.

Test plan

  • New regression tests, each asserting a toString() round trip preserves settings (parse -> render -> reparse
    -> compare settings maps), since the existing checkRightSyntax helper only proves the rendered text still
    parses, not that content survived:
    • ExportDatabaseStatementTestParserTest#toStringRoundTripsTheWithSettings
    • BackupDatabaseStatementTestParserTest#toStringRoundTripsTheWithSettings
    • RebuildIndexStatementTestParserTest#toStringRoundTripsTheWithSettings
    • RebuildIndexStatementTestParserTest#copyAndEqualsKeepTheWithSettings
  • All four failed against the pre-fix code, pass after.
  • Ran the full com.arcadedb.query.sql.parser test package, the broader RebuildIndex* executor tests
    (RebuildIndexOrphanBucketTest, RebuildIndexLockExhaustionTest, RebuildIndexPreservesNameTest,
    RebuildIndexPartitionValidationTest), and RebuildTypeRepartitionTest (covers the RebuildTypeStatement
    refactor) - all green.
  • mvn -o -pl engine -am compile clean.

Files changed

  • engine/src/main/java/com/arcadedb/query/sql/parser/Statement.java
  • engine/src/main/java/com/arcadedb/query/sql/parser/ExportDatabaseStatement.java
  • engine/src/main/java/com/arcadedb/query/sql/parser/BackupDatabaseStatement.java
  • engine/src/main/java/com/arcadedb/query/sql/parser/ImportDatabaseStatement.java
  • engine/src/main/java/com/arcadedb/query/sql/parser/RebuildIndexStatement.java
  • engine/src/main/java/com/arcadedb/query/sql/parser/RebuildTypeStatement.java
  • engine/src/test/java/com/arcadedb/query/sql/parser/ExportDatabaseStatementTestParserTest.java
  • engine/src/test/java/com/arcadedb/query/sql/parser/BackupDatabaseStatementTestParserTest.java
  • engine/src/test/java/com/arcadedb/query/sql/parser/RebuildIndexStatementTestParserTest.java

…settings when re-rendered to text

ExportDatabaseStatement#toString() and BackupDatabaseStatement#toString() only rendered url, never
settings, so re-serializing a parsed statement (statement caching keyed on text, query logging, an
audit trail) silently lost the WITH clause. Widening the fix to the rest of the WITH-settings statement
family found RebuildIndexStatement had the same gap in toString(), plus two related ones copy() never
carried settings over at all (the same silent-drop shape #6080/#6409 fixed for Export/Backup/Import),
and equals()/hashCode() never compared them, so two rebuilds with different settings compared equal.

Introduced Statement#appendWithSettings() as the one shared renderer for the WITH clause and pointed all
five settings-bearing statements at it (REBUILD INDEX, REBUILD TYPE, IMPORT/EXPORT/BACKUP DATABASE),
replacing four copies of the same loop.
@lvca lvca self-assigned this Aug 18, 2026
@mergify

mergify Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@claude

claude Bot commented Aug 18, 2026

Copy link
Copy Markdown

Review

Reviewed the diff, the touched files' surrounding context, and the sibling Export/Backup/ImportDatabaseStatement implementations this PR mirrors. Overall this is a clean, well-scoped fix - solid root-cause diagnosis, and the choice to widen the fix to the whole WITH-settings family (REBUILD INDEX/REBUILD TYPE/IMPORT/EXPORT/BACKUP DATABASE) rather than patch only the two statements named in #6428 is the right call given they all share the identical bug shape.

Code quality

  • Statement#appendWithSettings() is a good extraction: it's byte-for-byte identical to the four loop bodies it replaces (confirmed by diffing against the old ImportDatabaseStatement/RebuildTypeStatement code), so the refactor is behavior-preserving and removes real duplication.
  • RebuildIndexStatement.copy()/equals()/hashCode() now match the pattern already used by Export/Backup/ImportDatabaseStatement (shallow settings.putAll(...), Objects.equals(settings, that.settings)). Good consistency across the family.
  • Minor, non-blocking inconsistency: RebuildTypeStatement.copy() deep-copies the settings map's keys/values (result.settings.put(e.getKey().copy(), e.getValue().copy())), whereas RebuildIndexStatement/Export/Backup/Import all do a shallow putAll. That's pre-existing and not introduced by this PR, and Expression nodes are effectively immutable post-parse in practice, so it's very unlikely to bite - just flagging the divergence in case a future pass wants to normalize it.

Bugs

Test coverage

  • Good instinct calling out that checkRightSyntax alone doesn't catch this class of bug - since the dropped WITH clause still leaves syntactically valid text, checkRightSyntax's reparse-what-you-rendered check silently passes even with the bug present. The new toStringRoundTripsTheWithSettings tests correctly assert on actual settings-map equality after the round trip, which is what actually exercises the fix.
  • RebuildIndexStatementTestParserTest#copyAndEqualsKeepTheWithSettings covers copy(), equals(), and the negative case (different settings → not equal) in one place - nice and tight.
  • No dedicated round-trip regression test was added for RebuildTypeStatement, but the PR notes it was "already correct" pre-fix and exercised by RebuildTypeRepartitionTest; reasonable to not duplicate coverage for a non-behavior-changing refactor.

Performance / security

  • No concerns. This is confined to the SQL parser's AST rendering/copying/equality; no new allocations beyond what the old per-class loops already did, and no external input handling changes.

Nice, focused fix with tests that actually pin down the regression rather than just re-validating syntax.

@codacy-production

codacy-production Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 4 complexity

Metric Results
Complexity 4

View in Codacy

🟢 Coverage ∅ diff coverage · -6.56% coverage variation

Metric Results
Coverage variation ✅ -6.56% coverage variation
Diff coverage ✅ ∅ diff coverage

View coverage diff in Codacy

Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (e557d68) 161265 128321 79.57%
Head commit (27050dd) 193652 (+32387) 141382 (+13061) 73.01% (-6.56%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6434) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@codecov

codecov Bot commented Aug 18, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.91%. Comparing base (e557d68) to head (27050dd).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6434      +/-   ##
==========================================
+ Coverage   70.90%   70.91%   +0.01%     
==========================================
  Files        1855     1855              
  Lines      161265   161265              
  Branches    33874    33874              
==========================================
+ Hits       114342   114363      +21     
+ Misses      32983    32964      -19     
+ Partials    13940    13938       -2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@lvca lvca added this to the 26.9.1 milestone Aug 19, 2026
@lvca
lvca merged commit 2a77d34 into main Aug 19, 2026
48 of 49 checks passed
@lvca
lvca deleted the issue-6428 branch August 19, 2026 00:48
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.

Follow-ups from #6409: EXPORT/BACKUP DATABASE toString() drops WITH settings, and the node-identity sweep isn't exhaustive

1 participant