Skip to content

Add SQL mode compat query to db import command #170

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

Merged
merged 2 commits into from
Apr 18, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 8 additions & 10 deletions src/DB_Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,8 @@ public function import( $args, $assoc_args ) {
? 'SOURCE %s;'
: 'SET autocommit = 0; SET unique_checks = 0; SET foreign_key_checks = 0; SOURCE %s; COMMIT;';

$query = $this->get_sql_mode_query( $assoc_args ) . $query;

$mysql_args['execute'] = sprintf( $query, $result_file );
} else {
$result_file = 'STDIN';
Expand Down Expand Up @@ -1834,16 +1836,12 @@ protected function get_current_sql_modes( $assoc_args ) {

// Make sure the provided arguments don't interfere with the expected
// output here.
$args = $assoc_args;
unset(
$args['column-names'],
$args['result-format'],
$args['json'],
$args['html'],
$args['table'],
$args['tabbed'],
$args['vertical']
);
$args = [];
foreach ( [] as $arg ) {
if ( isset( $assoc_args[ $arg ] ) ) {
$args[ $arg ] = $assoc_args[ $arg ];
}
}

if ( null === $modes ) {
$modes = [];
Expand Down