fix(ebean-dao): honor isTestMode in batchUpsert and create paths#624
Merged
Conversation
prepareMultiColumnInsert hardcoded getTableName(urn), silently dropping the isTestMode flag both callers passed. Both batchUpsert and create therefore always wrote to the production table even when the caller requested test mode, which made test-table dual-write features (e.g. the shadow write in metadata-graph-assets) effectively double-write to production. Thread isTestMode into prepareMultiColumnInsert and route between getTableName / getTestTableName at the SQL build site, matching the pattern already used by the per-aspect add path and the helpers in SQLStatementUtils. Adds a regression test for the batchUpsert + isTestMode=true case and the missing metadata_entity_foo_test schema rows in both test SQL fixtures.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #624 +/- ##
=========================================
Coverage 66.82% 66.83%
- Complexity 1880 1881 +1
=========================================
Files 148 148
Lines 7262 7263 +1
Branches 879 880 +1
=========================================
+ Hits 4853 4854 +1
Misses 2024 2024
Partials 385 385 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
mridul111998
approved these changes
May 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem & Solution Overview
EbeanLocalAccess.prepareMultiColumnInserthardcodedgetTableName(urn)and ignored theisTestModeflag both callers (batchUpsertandcreate) passed in. As a result the test-table dual-write feature in metadata-graph-assets (which callsdao.batchUpsert(...)withIngestionParams.setTestMode(true)) silently wrote to the production table; the test table was never populated.This PR threads
isTestModeintoprepareMultiColumnInsertand routes betweengetTableName/getTestTableNameat the single SQL build site (line 945), matching the pattern already used by the per-aspectaddpath and by every helper inSQLStatementUtils(e.g.createAspectUpsertSql,createReadDeletionInfoByUrnsSql).Testing Done
testBatchUpsertWithTestModeWritesToTestTableinEbeanLocalAccessTest— exercisesbatchUpsert(..., isTestMode=true)and verifies the row lands in the test table viabatchGetUnion(..., isTestMode=true).metadata_entity_foo_testschema rows (table +a_urn+a_aspectfoocolumns) to bothebean-local-access-create-all.sqlfixture files so the test fixture mirrors the prod table for the columns the upsert touches.EbeanLocalAccessTestsuite passes (no regression from the schema additions).Notes for Reviewers
The equivalent fix for the
addandaddWithOptimisticLockingpaths is already correct (line 193 callsSQLStatementUtils.createAspectUpsertSql(urn, aspectClass, urnExtraction, isTestMode)). This bug was specific to the multi-column insert helper used only bybatchUpsertandcreate.The
ON DUPLICATE KEY UPDATEclause builders (buildOnDuplicateKeyForUpsert,buildOnDuplicateKeyForCreate) reference column names only, not the table name, so they did not need to change.🤖 Generated with Claude Code