-
Notifications
You must be signed in to change notification settings - Fork 32
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow for passthrough of extra args to pg_dump #26
Conversation
This is a potential fix for #23 |
Hi! Just wanted to see if there are any questions I can answer or anything else I can do to help get this PR reviewed. |
Hi @alexhall! Thank you for your contribution and sorry for the delay. Your addition seems legit and I guess it's a good move.
Oops sorry about that! The only thing I want to be sure is: will this command (the default command) still work? (TBH I don't remember how to test a CLI without publishing it so I prefer asking)
|
Hi @rap2hpoutre, thanks for getting back to me!
Yes, I can confirm that this still works. Here's a simple test run to demonstrate:
|
This would be a huge win for our use! |
# [0.6.0](v0.5.1...v0.6.0) (2022-07-08) ### Features * allow for passthrough of extra args to pg_dump ([#26](#26)) ([776b5be](776b5be))
Thank you for your contribution (and sorry for the late answer!) |
🎉 This PR is included in version 0.6.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
I started off looking for a way to restrict the anonymized database dump to a particular schema, which
pg_dump
already supports via the-n
flag. While we could conceivably define an equivalent pg-anonymizer flag and pass it through, thepg_dump
tool already supports a rich variety of CLI flags that help control what objects get dumped and we wouldn't want to have to define separate flags for each one that somebody might want to use.A more flexible approach, as implemented here, could be to switch from a single, named positional arg (a database connection string) to instead use variable-length arguments which we can then pass through to pg_dump (after sanitizing to ensure that we aren't breaking pg-anonymizer by altering the dump format or writing to a file rather than stdout).
By setting the
strict = false
flag, we instruct he OCLIF arg parser to gather up any unrecognized flags as positional arguments which are then exposed inargv
. You can also force the issue by using the special--
argument to separate flags from arguments a la GNU getopt. So the following commands are equivalent and both result in passing-n myschema mydb
to pg_dump:I believe this change to be fully backwards compatible with the existing CLI-parsing behavior, but in the absence of a test suite I'm not sure what the best way of demonstrating that might be.