Repository navigation
fix(#6428): EXPORT/BACKUP DATABASE and REBUILD INDEX drop their WITH settings when re-rendered to text - #6434
Conversation
…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.
|
Tick the box to add this pull request to the merge queue (same as
|
ReviewReviewed the diff, the touched files' surrounding context, and the sibling Code quality
Bugs
Test coverage
Performance / security
Nice, focused fix with tests that actually pin down the regression rather than just re-validating syntax. |
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 4 |
🟢 Coverage ∅ diff coverage · -6.56% coverage variation
Metric Results Coverage variation ✅ -6.56% coverage variation Diff coverage ✅ ∅ diff coverage 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Summary
Fixes #6428.
ExportDatabaseStatement#toString()andBackupDatabaseStatement#toString()only renderedurl, neversettings- re-serializing a parsed statement (statement caching keyed on text, query logging, an audit trail)silently dropped the
WITHclause.RebuildIndexStatement(part of the same five-statementWITH-settings family:REBUILD INDEX,REBUILD TYPE,IMPORT/EXPORT/BACKUP DATABASE) has the identicaltoString()gap, plus tworelated ones not named in the issue text:
copy()never carriedsettingsover at all - the same silent-drop shape feat(#6072): faster full backup - configurable compression level and parallel compression #6080/Follow-ups from #6401: two shapes for a WITH settings key, a duplicate setting that means three different things, and a sweep for nodes whose identity does not work #6409 already fixed forExport/Backup/ImportDatabaseStatement.equals()/hashCode()never comparedsettings- so twoREBUILD INDEXstatements with different settingscompared equal, the same over-match direction Follow-ups from #6401: two shapes for a WITH settings key, a duplicate setting that means three different things, and a sweep for nodes whose identity does not work #6409's identity sweep found for
ImportDatabaseStatement.Statement#appendWithSettings()as one shared renderer for theWITH key = value, ...clause andpointed all five settings-bearing statements at it, replacing four near-identical copies of the same loop
(
ImportDatabaseStatementandRebuildTypeStatementalready rendered it correctly; refactored onto the sharedhelper for consistency, no behavior change there).
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
toString()round trip preservessettings(parse -> render -> reparse-> compare settings maps), since the existing
checkRightSyntaxhelper only proves the rendered text stillparses, not that content survived:
ExportDatabaseStatementTestParserTest#toStringRoundTripsTheWithSettingsBackupDatabaseStatementTestParserTest#toStringRoundTripsTheWithSettingsRebuildIndexStatementTestParserTest#toStringRoundTripsTheWithSettingsRebuildIndexStatementTestParserTest#copyAndEqualsKeepTheWithSettingscom.arcadedb.query.sql.parsertest package, the broaderRebuildIndex*executor tests(
RebuildIndexOrphanBucketTest,RebuildIndexLockExhaustionTest,RebuildIndexPreservesNameTest,RebuildIndexPartitionValidationTest), andRebuildTypeRepartitionTest(covers theRebuildTypeStatementrefactor) - all green.
mvn -o -pl engine -am compileclean.Files changed
engine/src/main/java/com/arcadedb/query/sql/parser/Statement.javaengine/src/main/java/com/arcadedb/query/sql/parser/ExportDatabaseStatement.javaengine/src/main/java/com/arcadedb/query/sql/parser/BackupDatabaseStatement.javaengine/src/main/java/com/arcadedb/query/sql/parser/ImportDatabaseStatement.javaengine/src/main/java/com/arcadedb/query/sql/parser/RebuildIndexStatement.javaengine/src/main/java/com/arcadedb/query/sql/parser/RebuildTypeStatement.javaengine/src/test/java/com/arcadedb/query/sql/parser/ExportDatabaseStatementTestParserTest.javaengine/src/test/java/com/arcadedb/query/sql/parser/BackupDatabaseStatementTestParserTest.javaengine/src/test/java/com/arcadedb/query/sql/parser/RebuildIndexStatementTestParserTest.java