Skip to content

Commit a831815

Browse files
ngmyiamcal
authored andcommitted
Add tests for escaped quote decoding
1 parent 947083e commit a831815

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

tests/FieldTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,46 @@ function testSets(){
287287

288288
# ENUM(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name]
289289
# SET(value1,value2,value3,...) [CHARACTER SET charset_name] [COLLATE collation_name]
290+
291+
# a `\'` inside a string quoted with `'`
292+
$tbl = $this->get_first_table("CREATE TABLE foo (bar ENUM('hel\'lo'))");
293+
$this->assertEquals($tbl['fields'], array(
294+
array(
295+
'name' => "bar",
296+
'type' => "ENUM",
297+
'values' => array("hel'lo"),
298+
)
299+
));
300+
301+
# a `\"` inside a string quoted with `"`
302+
$tbl = $this->get_first_table('CREATE TABLE foo (bar ENUM("hel\"lo"))');
303+
$this->assertEquals($tbl['fields'], array(
304+
array(
305+
'name' => "bar",
306+
'type' => "ENUM",
307+
'values' => array('hel"lo'),
308+
)
309+
));
310+
311+
# a `\'` inside a string quoted with `"`
312+
$tbl = $this->get_first_table("CREATE TABLE foo (bar ENUM(\"hel\'lo\"))");
313+
$this->assertEquals($tbl['fields'], array(
314+
array(
315+
'name' => "bar",
316+
'type' => "ENUM",
317+
'values' => array("hel'lo"),
318+
)
319+
));
320+
321+
# a `\"` inside a string quoted with `'`
322+
$tbl = $this->get_first_table('CREATE TABLE foo (bar ENUM(\'hel\"lo\'))');
323+
$this->assertEquals($tbl['fields'], array(
324+
array(
325+
'name' => "bar",
326+
'type' => "ENUM",
327+
'values' => array('hel"lo'),
328+
)
329+
));
290330
}
291331

292332

0 commit comments

Comments
 (0)