fix: Re-importable Bulk Export Closure and Lookup Master Fixes#128
Merged
ilramdhan merged 4 commits intoJun 23, 2026
Merged
Conversation
Add ProductSysIDs filter to ExportRequest. When set, resolveProductClosure() performs a BFS from the seed products through PRODUCT-type route RMs, collecting every intermediate product in the dependency tree. The export includes all products in the closure so the resulting Excel is fully re-importable without broken references. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Migration 000394 seeded lm_code_field/lm_label_field with camelCase proto field names (e.g. machineCode, pgCode) instead of actual snake_case DB column names (mc_code, pg_code). ListMasterOptions uses these values directly in dynamic SQL, so all lookup dropdowns returned empty results. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Use product_code as the universal cross-sheet key (legacy_oracle_sys_id) instead of flex_02 (empty for in-app products) so exports from app-created products always have a non-empty, stable identifier - Add data_type column to product_parameters sheet (required by import validator) - Filter cpp/capp rows to only include products in the export closure - Fix route_head/route_sequences/route_rms to use product_code instead of raw integer product_sys_id / head_id, so sheet cross-references resolve - Fix SQLSTATE 42P08: add explicit $8::text cast in BulkUpsertByLegacyID subquery to prevent PostgreSQL 18 type inference failure when the same parameter appears in both VALUES and a correlated subquery - Align template sheet names with what the import handler expects (product_parameters, product_applicable_params, route_sequences, route_rms) and fix column headers to match the actual importer field names Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- Extract loadRoutingData helper from loadExportData (gocyclo 17→11) - Extract buildExportCodeMaps, filterCPPByProductCode, filterCAPPByProductCode helpers from generateExcel (gocyclo 16→10) - Add nolint:gocognit on resolveProductClosure (BFS traversal is inherently nested and cannot be split without losing clarity) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Description
This PR significantly enhances the Bulk Export feature, ensuring that any generated Excel file is fully "re-importable" across different environments without breaking relational dependencies.
It achieves this by implementing a Breadth-First Search (BFS) closure that automatically exports the entire dependency tree of a selected product. Additionally, it transitions the universal cross-sheet key from
flex_02toproduct_code, ensuring stability for products created within the app rather than imported from Oracle. It also resolves a dynamic SQL issue where lookup dropdowns were returning empty results due to incorrect column name mapping.Type of Change
Service(s) Affected
Changes Made
📤 Re-importable Bulk Export Closure
ProductSysIDsfilter toExportRequest. AddedresolveProductClosure()which performs a BFS from the seed products, crawling throughPRODUCT-type route RMs to collect every intermediate product in the dependency tree. The resulting export includes the full closure, guaranteeing no broken references on re-import.flex_02toproduct_code.flex_02is empty for products created directly within the app, causing export/import failures.product_codeensures a stable, non-empty identifier.route_head,route_sequences, androute_rmssheets to useproduct_codeinstead of raw integer IDs (product_sys_id/head_id) so that sheet cross-references resolve correctly during import.product_parameters,product_applicable_params,route_sequences,route_rms) and added thedata_typecolumn to theproduct_parameterssheet to strictly match the import validator's expectations.cppandcapprows are now strictly filtered to only include products present in the export closure.🐛 Bug Fixes
ListMasterOptionsreturned empty dropdowns. Migration 000394 originally seededlm_code_fieldandlm_label_fieldwith camelCase proto fields (e.g.,machineCode). This is now corrected to use actual snake_case DB column names (e.g.,mc_code) for dynamic SQL mapping.$8::textcast in theBulkUpsertByLegacyIDsubquery to prevent type inference failures when the same parameter appears in bothVALUESand a correlated subquery.Related Issues
Fixes #
Related to #
API Changes (if applicable)
Proto Changes
Breaking Changes
None.
Testing Performed
Unit Tests
Integration Tests
Manual Testing
Lint & Build
golangci-lint run ./...passesgo build ./...succeedsgo test -race ./...passesDatabase (if applicable)
Documentation
Rollback Plan
Revert the
finance-servicedeployment to the previous stable tag. Reverting will cause exports of app-created products to use the oldflex_02key, which may not be re-importable, but will not corrupt any existing database state.Screenshots/Logs (if applicable)
Pre-merge Checklist
Reviewer Notes
resolveProductClosureBFS algorithm safely collects the entire tree structure. Circular dependencies are natively avoided by tracking visitedproduct_codes.ON CONFLICTsubqueries fail parser resolution.