Skip to content

Commit

Permalink
Merge pull request #170 from wp-cli/add-sql-mode-compat-to-import
Browse files Browse the repository at this point in the history
Add SQL mode compat query to db import command
  • Loading branch information
schlessera authored Apr 18, 2020
2 parents 80eb284 + 2f031ba commit 8623594
Showing 1 changed file with 8 additions and 10 deletions.
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

0 comments on commit 8623594

Please sign in to comment.