Skip to content

Commit 511af61

Browse files
committed
Add test case for alphanumeric string with e character
1 parent 8278d08 commit 511af61

2 files changed

Lines changed: 41 additions & 0 deletions

File tree

‎features/bootstrap/SQLiteFeatureContext.php‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,27 @@ public function theFileShouldNotContain( $filename, PyStringNode $content ) {
166166
throw new Exception( "File contains unexpected content:\n" . $content );
167167
}
168168
}
169+
170+
/**
171+
* @Given /^the SQLite database contains a test table with alphanumeric string hash values$/
172+
*/
173+
public function theSqliteDatabaseContainsATestTableWithAlphanumericStringHashValues() {
174+
$this->connectToDatabase();
175+
176+
// Create a test table with hash values that look like scientific notation
177+
$this->db->exec("DROP TABLE IF EXISTS test_export_alphanumeric_string");
178+
$this->db->exec("
179+
CREATE TABLE test_export_alphanumeric_string (
180+
id INTEGER PRIMARY KEY,
181+
hash_value TEXT
182+
)
183+
");
184+
185+
// Insert test data with values that might be mistaken for scientific notation
186+
$this->db->exec("
187+
INSERT INTO test_export_alphanumeric_string (id, hash_value) VALUES
188+
(1, '123e99')
189+
");
190+
}
191+
169192
}

‎features/sqlite-export.feature‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,3 +115,21 @@ Feature: WP-CLI SQLite Export Command
115115
"""
116116
CREATE TABLE `wp_users`
117117
"""
118+
119+
@require-sqlite
120+
Scenario: Export should escape alphanumeric strings with e character
121+
Given the SQLite database contains a test table with alphanumeric string hash values
122+
When I run `wp sqlite export test_export_alphanumeric_string.sql --tables=test_export_alphanumeric_string`
123+
Then STDOUT should contain:
124+
"""
125+
Success: Export complete. File written to test_export_alphanumeric_string.sql
126+
"""
127+
And the file "test_export_alphanumeric_string.sql" should exist
128+
And the file "test_export_alphanumeric_string.sql" should contain:
129+
"""
130+
INSERT INTO `test_export_alphanumeric_string` VALUES (1,'123e99');
131+
"""
132+
But the file "test_export_alphanumeric_string.sql" should not contain:
133+
"""
134+
INSERT INTO `test_export_alphanumeric_string` VALUES (1,123e99);
135+
"""

0 commit comments

Comments
 (0)