fix(dataset): Add DTD-declared zero-row tables missing from flat XML body - #916
Conversation
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Reviewer's GuideFlatXmlProducer now ensures that tables declared in DTD or an explicit metadata IDataSet but never referenced by any row element are still emitted as empty tables in the produced IDataSet, preventing CLEAN_INSERT/DELETE_ALL from skipping genuinely empty fixture tables; this is implemented by a new addMissingDtdTables() hook invoked at dataset end and covered by new unit tests plus a changelog entry. Sequence diagram for FlatXmlProducer endElement with addMissingDtdTablessequenceDiagram
participant SaxParser
participant FlatXmlProducer
participant metaDataSet as IDataSet
participant tableMap as OrderedTableNameMap
participant consumer as IDataSetConsumer
SaxParser->>FlatXmlProducer: endElement(uri, localName, qName)
alt [end of dataset]
FlatXmlProducer->>FlatXmlProducer: addMissingDtdTables()
FlatXmlProducer->>metaDataSet: getTableNames()
loop dtdTableNames
FlatXmlProducer->>tableMap: containsTable(dtdTableName)
alt [table missing]
FlatXmlProducer->>metaDataSet: getTableMetaData(dtdTableName)
FlatXmlProducer->>tableMap: add(tableName, metaData)
FlatXmlProducer->>consumer: startTable(metaData)
FlatXmlProducer->>consumer: endTable()
end
end
FlatXmlProducer->>consumer: endDataSet()
end
File-Level Changes
Assessment against linked issues
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Warning Review limit reached
Next review available in: 47 minutes You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthrough
ChangesEmpty declared tables
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/test/java/org/dbunit/dataset/xml/FlatXmlProducerTest.java`:
- Around line 169-175: Update the FlatXmlProducerTest cases at
src/test/java/org/dbunit/dataset/xml/FlatXmlProducerTest.java:169-175 and
243-255 to use distinct column metadata for each table: make MISSING_TABLE
differ from PRESENT_TABLE, and declare/expect different columns for
PRESENT_TABLE, MISSING_TABLE_A, and MISSING_TABLE_B. Preserve the existing
assertions while ensuring the unit tests detect columns being incorrectly reused
between tables.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: b295539a-e566-4d6d-b68b-81f5b326f1a8
📒 Files selected for processing (3)
src/changes/changes.xmlsrc/main/java/org/dbunit/dataset/xml/FlatXmlProducer.javasrc/test/java/org/dbunit/dataset/xml/FlatXmlProducerTest.java
…body FlatXmlProducer only registered a table inside startElement()'s new-table handling, so a table declared in the DTD but never used by a row element (a genuinely empty fixture table) was silently absent from the produced dataset. CLEAN_INSERT/DELETE_ALL would then skip it, risking a foreign-key violation against data a prior test left behind. * Add FlatXmlProducer#addMissingDtdTables(), called from endElement() right before endDataSet(); it cross-references every table name reported by the available metadata source (parsed DTD, or an explicitly-supplied metadata IDataSet) against the tables actually encountered in the XML body, and reports any still missing as an empty table via the consumer, using that source's column metadata. * No-op when no DTD/metadata dataset is available, so behavior for plain flat XML is unchanged. Refs: 496
bf9de81 to
05f1b50
Compare
Summary
FlatXmlProduceronly registered a table insidestartElement()'s new-table handling, so a table declared in the DTD but never used by a row element (a genuinely empty fixture table) was silently absent from the produced dataset.CLEAN_INSERT/DELETE_ALLwould then skip such a table entirely, risking a foreign-key violation against data a prior test left behind.FlatXmlProducer#addMissingDtdTables(), called fromendElement()right beforeendDataSet(): it cross-references every table name reported by the available metadata source (parsed DTD, or an explicitly-supplied metadataIDataSet) against the tables actually encountered in the XML body, and reports any still missing as an empty table via the consumer, using that source's column metadata.Test plan
FlatXmlProducerTest#testProduce_withDtdTablesAbsentFromXmlBody_addsEmptyTablesInDtdOrder(DTD parsed viaEntityResolver)FlatXmlProducerTest#testProduceMetaDataSet_withTableAbsentFromXmlBody_addsEmptyTableFromMetaDataSet(explicit metaDataSet constructor)sortedTableTest.xml) is unaffectedhsqldb-2-7integration suite: 356 tests, 0 failuresFixes #496
🤖 Generated with Claude Code
https://claude.ai/code/session_012gmZhDioasFdPtnqxs1ZuP
Summary by Sourcery
Ensure flat XML datasets include DTD-declared tables that have no rows so downstream operations see the full table set.
Bug Fixes:
Documentation:
Tests:
Summary by CodeRabbit