-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add --skip-* options to lower flags #36
Open
beuss
wants to merge
1
commit into
machbarmacher:master
Choose a base branch
from
beuss:skip-options
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+36
−15
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,17 @@ | |
|
||
class DumpCommand extends Command | ||
{ | ||
// Options that can be negated through skip-[option], allows to have | ||
// defaults to true with explicit disablement. | ||
private static $skipable_options = [ | ||
'add-drop-table', | ||
'add-locks', | ||
'disable-keys', | ||
'extended-insert', | ||
'lock-tables', | ||
'quote-names', | ||
'opt' | ||
]; | ||
|
||
protected function configure() | ||
{ | ||
|
@@ -70,9 +81,9 @@ protected function configure() | |
InputOption::VALUE_OPTIONAL, | ||
'Default charset. Defaults to utf8mb4.', 'utf8mb4') | ||
->addOption('disable-keys', null, InputOption::VALUE_NONE, | ||
'Adds disable-keys statements for faster dump execution. Defaults to on, use no-disable-keys to switch off.') | ||
'Adds disable-keys statements for faster dump execution. Defaults to on, use skip-disable-keys to switch off.') | ||
->addOption('extended-insert', 'e', InputOption::VALUE_NONE, | ||
'Write INSERT statements using multiple-row syntax that includes several VALUES lists. This results in a smaller dump file and speeds up inserts when the file is reloaded. Defaults to on, use no-extended-insert to switch off.') | ||
'Write INSERT statements using multiple-row syntax that includes several VALUES lists. This results in a smaller dump file and speeds up inserts when the file is reloaded. Defaults to on, use skip-extended-insert to switch off.') | ||
->addOption('events', null, InputOption::VALUE_NONE, | ||
'Dump events from dumped databases ') | ||
->addOption('hex-blob', null, InputOption::VALUE_NONE, | ||
|
@@ -89,16 +100,6 @@ protected function configure() | |
'Dump stored routines (procedures and functions) from dumped databases.') | ||
->addOption('single-transaction', null, InputOption::VALUE_NONE, | ||
'Issue a BEGIN SQL statement before dumping data from server.') | ||
->addOption('skip-triggers', null, InputOption::VALUE_NONE, | ||
'Do not dump triggers.') | ||
->addOption('skip-tz-utc', null, InputOption::VALUE_NONE, | ||
'Turn off tz-utc.') | ||
->addOption('skip-comments', null, InputOption::VALUE_NONE, | ||
'Do not add comments to dump file.') | ||
->addOption('skip-dump-date', null, InputOption::VALUE_NONE, | ||
'Skip dump date to better compare dumps.') | ||
->addOption('skip-definer', null, InputOption::VALUE_NONE, | ||
'Omit DEFINER and SQL SECURITY clauses from the CREATE statements for views and stored programs.') | ||
->addOption('where', null, InputOption::VALUE_OPTIONAL, | ||
'Dump only rows selected by given WHERE condition.') | ||
->addOption('gdpr-expressions', null, InputOption::VALUE_OPTIONAL, | ||
|
@@ -113,9 +114,24 @@ protected function configure() | |
//->addOption('databases', NULL, InputOption::VALUE_OPTIONAL|InputOption::VALUE_IS_ARRAY, 'Dump several databases. Normally, mysqldump treats the first name argument on the command line as a database name and following names as table names. With this option, it treats all name arguments as database names.') | ||
// Add some options that e.g. drush expects. | ||
->addOption('quote-names', 'Q', InputOption::VALUE_NONE, | ||
'Currently ignored.') | ||
'Currently ignored (hardcoded to on in mysqldump-php).') | ||
->addOption('opt', null, InputOption::VALUE_NONE, | ||
'Implies --add-drop-table --add-locks --disable-keys --extended-insert --hex-blob --no-autocommit --single-transaction.'); | ||
'Implies --add-drop-table --add-locks --disable-keys --extended-insert --hex-blob --no-autocommit --single-transaction.') | ||
->addOption('skip-triggers', null, InputOption::VALUE_NONE, | ||
'Do not dump triggers.') | ||
->addOption('skip-tz-utc', null, InputOption::VALUE_NONE, | ||
'Turn off tz-utc.') | ||
->addOption('skip-comments', null, InputOption::VALUE_NONE, | ||
'Do not add comments to dump file.') | ||
->addOption('skip-dump-date', null, InputOption::VALUE_NONE, | ||
'Skip dump date to better compare dumps.') | ||
->addOption('skip-definer', null, InputOption::VALUE_NONE, | ||
'Omit DEFINER and SQL SECURITY clauses from the CREATE statements for views and stored programs.'); | ||
|
||
foreach(self::$skipable_options as $option) { | ||
$this->addOption("skip-$option", null, InputOption::VALUE_NONE, | ||
"Inhibits any previous explicit or implicit $option option."); | ||
} | ||
} | ||
|
||
/** | ||
|
@@ -171,7 +187,7 @@ public function getEffectivePassword( | |
protected function execute(InputInterface $input, OutputInterface $output) | ||
{ | ||
$dumpSettings = | ||
$this->getOptOptions($input->getOption('opt')) | ||
$this->getOptOptions($input->getOption('opt') && !$input->getOption('skip-opt')) | ||
+ $this->getDefaults($input->getOption('defaults-file')) | ||
+ array_filter($input->getArguments()) | ||
+ array_filter($input->getOptions()) | ||
|
@@ -185,6 +201,11 @@ protected function execute(InputInterface $input, OutputInterface $output) | |
], null); | ||
$user = $dumpSettings['user']; | ||
|
||
foreach(self::$skipable_options as $option) { | ||
if($input->getOption("skip-$option")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Missing space after if |
||
$dumpSettings[$option] = false; | ||
} | ||
} | ||
|
||
$dumpSettings['password'] = $this->getEffectivePassword($input, $output, $dumpSettings['password']); | ||
$password = $dumpSettings['password']; | ||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing space after foreach