Skip to content

xml: make -q honor TableMapping when -n is not set#67

Open
kroexov wants to merge 1 commit into
vmkteam:masterfrom
kroexov:fix/quiet-respects-table-mapping
Open

xml: make -q honor TableMapping when -n is not set#67
kroexov wants to merge 1 commit into
vmkteam:masterfrom
kroexov:fix/quiet-respects-table-mapping

Conversation

@kroexov
Copy link
Copy Markdown

@kroexov kroexov commented May 14, 2026

Summary

  • -q help promises it is ignored only when --namespaces (-n) is set, but the generator collapsed both Packages sources — explicit -n and implicit TableMapping from the mfd file — into a single nil check. On any real project (where TableMapping is populated) -q new therefore never prompted, making the flag effectively equivalent to -q all.
  • Split the two sources: options.Packages now strictly means "from -n"; TableMapping is consulted separately and combined with --quiet mode. Behaviour matrix after the fix:
    • -n set → -q is ignored (help contract), strict mapping, skip the rest.
    • -q all without -n → use TableMapping / existing entities, skip unmapped tables.
    • -q new without -n → use TableMapping / existing entities, prompt for the rest.
    • default → prompt for everything.
  • Table selection for the DB read is adjusted so that -q new/default without -t reads public.* (otherwise the prompt path could never trigger when TableMapping was non-empty).

Test plan

  • make db-test
  • go test -count=1 ./... — all packages pass, including existing TestGenerator_Generate.
  • New TestGenerator_QuietWithTableMapping covers three scenarios:
    • -q new + TableMapping{portal:news,categories,tags} → mapped tables are silent, new tables (vfsFiles, countries, …) go through the prompt and land in other.
    • -q all + TableMapping{card:encryptionKeys} (with -t public.encryptionKeys,public.vfsFolders) → no prompt, vfsFolders is skipped.
    • -n custom:encryptionKeys + -q new + TableMapping{portal:encryptionKeys}-n wins, portal namespace is not created.

Notes

  • Minimal API surface added for tests: a private promptNS field on Generator that overrides PromptNS. Reason: promptui.SelectWithAdd needs 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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant