Skip to content

Commit b56e566

Browse files
authored
Merge pull request #170 from wp-cli/add-sql-mode-compat-to-import
Add SQL mode compat query to db import command
2 parents c274b57 + edf69c8 commit b56e566

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/DB_Command.php

+8-10
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,8 @@ public function import( $args, $assoc_args ) {
651651
? 'SOURCE %s;'
652652
: 'SET autocommit = 0; SET unique_checks = 0; SET foreign_key_checks = 0; SOURCE %s; COMMIT;';
653653

654+
$query = $this->get_sql_mode_query( $assoc_args ) . $query;
655+
654656
$mysql_args['execute'] = sprintf( $query, $result_file );
655657
} else {
656658
$result_file = 'STDIN';
@@ -1834,16 +1836,12 @@ protected function get_current_sql_modes( $assoc_args ) {
18341836

18351837
// Make sure the provided arguments don't interfere with the expected
18361838
// output here.
1837-
$args = $assoc_args;
1838-
unset(
1839-
$args['column-names'],
1840-
$args['result-format'],
1841-
$args['json'],
1842-
$args['html'],
1843-
$args['table'],
1844-
$args['tabbed'],
1845-
$args['vertical']
1846-
);
1839+
$args = [];
1840+
foreach ( [] as $arg ) {
1841+
if ( isset( $assoc_args[ $arg ] ) ) {
1842+
$args[ $arg ] = $assoc_args[ $arg ];
1843+
}
1844+
}
18471845

18481846
if ( null === $modes ) {
18491847
$modes = [];

0 commit comments

Comments
 (0)