File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -34,6 +34,7 @@ public function theSqliteDatabaseShouldContainATableNamed( $table_name ) {
3434
3535 /**
3636 * @Then /^the "([^"]*)" should contain a row with name "([^"]*)"$/
37+ * @Then /^the "([^"]*)" should contain a row with name:$/
3738 */
3839 public function theTableShouldContainARowWithName ( $ table_name , $ name ) {
3940 $ this ->connectToDatabase ();
Original file line number Diff line number Diff line change @@ -67,3 +67,23 @@ Feature: WP-CLI SQLite Import Command
6767 And the "test_table" should contain a row with name "Test that escaping a character \a works"
6868 And the "test_table" should contain a row with name "Test that escaping a backslash followed by a character \\ a works"
6969 And the "test_table" should contain a row with name "Test that escaping a backslash and a character \\\a works"
70+
71+ @require-sqlite
72+ Scenario : Import a file with newlines in strings
73+ Given a SQL dump file named "test_import.sql" with content:
74+ """
75+ CREATE TABLE test_table (id INTEGER PRIMARY KEY AUTO_INCREMENT, name TEXT);
76+ INSERT INTO test_table (name) VALUES ('Test that a string containing
77+ a newline character and some whitespace works');
78+ """
79+ When I run `wp sqlite --enable-ast-driver import test_import.sql`
80+ Then STDOUT should contain:
81+ """
82+ Success: Imported from 'test_import.sql'.
83+ """
84+ And the SQLite database should contain a table named "test_table"
85+ And the "test_table" should contain a row with name:
86+ """
87+ Test that a string containing
88+ a newline character and some whitespace works
89+ """
Original file line number Diff line number Diff line change @@ -86,8 +86,6 @@ public function parse_statements( $sql_file_path ) {
8686 $ line = mb_convert_encoding ( $ line , 'UTF-8 ' , $ detected_encoding );
8787 }
8888
89- $ line = trim ( $ line );
90-
9189 // Skip empty lines and comments
9290 if ( empty ( $ line ) || strpos ( $ line , '-- ' ) === 0 || strpos ( $ line , '# ' ) === 0 ) {
9391 continue ;
You can’t perform that action at this time.
0 commit comments