Menu

#422 [Perl] the string Inserted through quote method is not expected

open
nobody
None
5
2013-02-21
2013-02-21
Jira Trac
No

[Perl] the string Inserted through quote method is not expected
Test case: http://svn.cubrid.org/cubridapis/perl/branches/RB-9.1.0/t2/Perl/_44_quote/cases/mysql_prepare_01.pl

Test Environment:
{noformat}
cubrid_rel: 9.1.0.0201
perl driver: http://svn.cubrid.org/cubridapis/perl/branches/RB-9.1.0 1499
perl: 5.14.2
{noformat}

Test Codes:
{code}
$dbh-do(drop table if EXISTS q1;) or die drop error: $dbh-errstr;

$dbh-do(create table q1(id int, a string)) or die create error: $dbh-errstr;

ok (my $sth=$dbh-prepare(insert into q1 values (?,?)),prepare ok);
ok ($sth-execute(1,$dbh-quote(single quote(') test)),prepare of select succeed);
ok ($sth-execute(2,$dbh-quote(new line(\n) test)),prepare of select succeed);
ok ($sth-execute(3,$dbh-quote(carrage return (\r) test)),prepare of select succeed);
ok ($sth-execute(4,$dbh-quote(backslash (\\) test)),prepare of select succeed);
ok ($sth-execute(5,$dbh-quote(backslash quote(\\') test)),prepare of select succeed);

my $sel_sql=select * from q1;
my $sth=$dbh-prepare($sel_sql) or warn(create error: $DBI::errstr);
$sth-execute() or warn(create error: $DBI::errstr);
my $arry=$sth-fetchall_arrayref({}) or die Arry error:$dbh-errstr;

my $i=0;
my @id=(1,2,3,4,5);
my @a=(qq(single quote(') test),new line(\n) test,carrage return (\r) test,backslash (\\) test,backslash quote(\\') test);
foreach my $row(@$arry){
is($row-{'id'},$id[$i],fetchall_arrayref({}) ok);
is($row-{'a'},$a[$i],fetchall_arrayref({}) ok);
$i++;
}
{code}

Test Result:
{noformat}
not ok 8 - fetchall_arrayref({}) ok
# Failed test 'fetchall_arrayref({}) ok'
# at Perl/_44_quote/cases/mysql_prepare_01.pl line 42.
# got: ''single quote('') test''
# expected: 'single quote(') test'
ok 9 - fetchall_arrayref({}) ok
not ok 10 - fetchall_arrayref({}) ok
# Failed test 'fetchall_arrayref({}) ok'
# at Perl/_44_quote/cases/mysql_prepare_01.pl line 42.
# got: ''new line(
# ) test''
# expected: 'new line(
# ) test'
ok 11 - fetchall_arrayref({}) ok
not ok 12 - fetchall_arrayref({}) ok
# Failed test 'fetchall_arrayref({}) ok'
# at Perl/_44_quote/cases/mysql_prepare_01.pl line 42.
) test'' got: ''carrage return (
) test'xpected: 'carrage return (
ok 13 - fetchall_arrayref({}) ok
not ok 14 - fetchall_arrayref({}) ok
# Failed test 'fetchall_arrayref({}) ok'
# at Perl/_44_quote/cases/mysql_prepare_01.pl line 42.
# got: ''backslash (\) test''
# expected: 'backslash (\) test'
ok 15 - fetchall_arrayref({}) ok
not ok 16 - fetchall_arrayref({}) ok
# Failed test 'fetchall_arrayref({}) ok'
# at Perl/_44_quote/cases/mysql_prepare_01.pl line 42.
# got: ''backslash quote(\'') test''
# expected: 'backslash quote(\') test'
1..16
{noformat}

Discussion

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.