xml: make -q honor TableMapping when -n is not set#67
Open
kroexov wants to merge 1 commit into
Open
Conversation
The help for -q states it is ignored only when --namespaces (-n) is set, but the generator collapsed both sources of Packages — explicit -n and implicit TableMapping from mfd — into a single nil-check, so -q new effectively never prompted on real projects whose TableMapping is populated. Split the two sources: Packages stays "from -n", TableMapping is consulted separately and combined with --quiet. -q new now prompts for tables that are absent from TableMapping; -q all still skips them; -n keeps full precedence over TableMapping as the help promises. Add integration tests covering all three combinations using a fake prompt hook injected into the generator.
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.
Summary
-qhelp promises it is ignored only when--namespaces(-n) is set, but the generator collapsed both Packages sources — explicit-nand implicitTableMappingfrom the mfd file — into a single nil check. On any real project (whereTableMappingis populated)-q newtherefore never prompted, making the flag effectively equivalent to-q all.options.Packagesnow strictly means "from-n";TableMappingis consulted separately and combined with--quietmode. Behaviour matrix after the fix:-nset →-qis ignored (help contract), strict mapping, skip the rest.-q allwithout-n→ useTableMapping/ existing entities, skip unmapped tables.-q newwithout-n→ useTableMapping/ existing entities, prompt for the rest.-q new/default without-treadspublic.*(otherwise the prompt path could never trigger whenTableMappingwas non-empty).Test plan
make db-testgo test -count=1 ./...— all packages pass, including existingTestGenerator_Generate.TestGenerator_QuietWithTableMappingcovers three scenarios:-q new+TableMapping{portal:news,categories,tags}→ mapped tables are silent, new tables (vfsFiles,countries, …) go through the prompt and land inother.-q all+TableMapping{card:encryptionKeys}(with-t public.encryptionKeys,public.vfsFolders) → no prompt,vfsFoldersis skipped.-n custom:encryptionKeys+-q new+TableMapping{portal:encryptionKeys}→-nwins,portalnamespace is not created.Notes
promptNSfield onGeneratorthat overridesPromptNS. Reason:promptui.SelectWithAddneeds a real TTY; testing it without injection would require a PTY harness (e.g.go-expect) and Unix-only test infra. Happy to switch to that approach if preferred.