Skip to content

Commit 8f61784

Browse files
author
Ulf Wendel
committed
Fixing tests to run with SQL_MODE=ANSI_QUOTES as well.
1 parent b4dac2a commit 8f61784

8 files changed

+21
-21
lines changed

ext/mysql/tests/connect.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,4 @@ $TEST_EXPERIMENTAL = (in_array(getenv("MYSQL_TEST_EXPERIMENTAL"), array(0, 1)))
6262
false;
6363

6464
$IS_MYSQLND = stristr(mysql_get_client_info(), "mysqlnd");
65-
?>
65+
?>

ext/mysql/tests/mysql_affected_rows.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,18 @@ if (!mysql_query('DROP TABLE IF EXISTS test', $link))
3535
if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGINE = ' . $engine, $link))
3636
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
3737

38-
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link))
38+
if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a')", $link))
3939
printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
4040

4141
if (1 !== ($tmp = mysql_affected_rows($link)))
4242
printf("[010] Expecting int/1, got %s/%s\n", gettype($tmp), $tmp);
4343

4444
// ignore INSERT error, NOTE: command line returns 0, affected_rows returns -1 as documented
45-
@mysql_query('INSERT INTO test(id, label) VALUES (1, "a")', $link);
45+
@mysql_query("INSERT INTO test(id, label) VALUES (1, 'a')", $link);
4646
if (-1 !== ($tmp = mysql_affected_rows($link)))
4747
printf("[011] Expecting int/-1, got %s/%s\n", gettype($tmp), $tmp);
4848

49-
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a") ON DUPLICATE KEY UPDATE id = 4', $link))
49+
if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a') ON DUPLICATE KEY UPDATE id = 4", $link))
5050
printf("[012] [%d] %s\n", mysql_errno($link), mysql_error($link));
5151

5252
if (2 !== ($tmp = mysql_affected_rows($link)))

ext/mysql/tests/mysql_field_flags.phpt

+5-5
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ $tables = array(
5353
'label' => array(($version < 500) ? 'multiple_key' : 'unique_key')
5454
),
5555
'labela INT, label2 CHAR(1), KEY keyname (labela, label2)' => array(
56-
array('labela, label2', '1, "a"'),
56+
array('labela, label2', "1, 'a'"),
5757
'labela' => array('multiple_key'),
5858
),
5959
'label1 BLOB' => array(
60-
array('label1', '"blob"'),
60+
array('label1', "'blob'"),
6161
'label1' => array('blob', 'binary'),
6262
),
6363
'label1 INT UNSIGNED' => array(
@@ -70,15 +70,15 @@ $tables = array(
7070
'unsigned'),
7171
),
7272
'label1 ENUM("a", "b")' => array(
73-
array('label1', '"a"'),
73+
array('label1', "'a'"),
7474
'label1' => array('enum'),
7575
),
7676
'label1 SET("a", "b")' => array(
77-
array('label1', '"a"'),
77+
array('label1', "'a'"),
7878
'label1' => array('set'),
7979
),
8080
'label1 TIMESTAMP' => array(
81-
array('label1', sprintf('"%s"', @date("Y-m-d H:i:s"))),
81+
array('label1', sprintf("'%s'", @date("Y-m-d H:i:s"))),
8282
'label1' => array(
8383
'timestamp',
8484
'unsigned',

ext/mysql/tests/mysql_info.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ if (NULL !== ($tmp = @mysql_info(NULL)))
1616
printf("[002] Expecting NULL, got %s/%s\n", gettype($tmp), $tmp);
1717

1818
require "table.inc";
19-
if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (100, "a")', $link))
19+
if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (100, 'a')", $link))
2020
printf("[003] [%d] %s\n", mysql_errno($link), mysql_error($link));
2121

2222
if (false !== ($tmp = mysql_info($link)))
2323
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
2424

25-
if (!$res = mysql_query('INSERT INTO test(id, label) VALUES (101, "a"), (102, "b")', $link))
25+
if (!$res = mysql_query("INSERT INTO test(id, label) VALUES (101, 'a'), (102, 'b')", $link))
2626
printf("[005] [%d] %s\n", mysql_errno($link), mysql_error($link));
2727

2828
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
@@ -40,7 +40,7 @@ if (!$res = mysql_query('ALTER TABLE test MODIFY label CHAR(2)', $link))
4040
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))
4141
printf("[010] Expecting string/any_non_empty, got %s/%s\n", gettype($tmp), $tmp);
4242

43-
if (!$res = mysql_query('UPDATE test SET label = "b" WHERE id >= 100', $link))
43+
if (!$res = mysql_query("UPDATE test SET label = 'b' WHERE id >= 100", $link))
4444
printf("[011] [%d] %s\n", mysql_errno($link), mysql_error($link));
4545

4646
if (!is_string($tmp = mysql_info($link)) || ('' == $tmp))

ext/mysql/tests/mysql_query.phpt

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,26 @@ if (NULL !== ($tmp = @mysql_query("SELECT 1 AS a", $link, "foo")))
2626
if (false !== ($tmp = mysql_query('THIS IS NOT SQL', $link)))
2727
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
2828

29-
if (false !== ($tmp = mysql_query('SELECT "this is sql but with backslash g"\g', $link)))
29+
if (false !== ($tmp = mysql_query("SELECT 'this is sql but with backslash g'\g", $link)))
3030
printf("[005] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
3131

3232
if ((0 === mysql_errno($link)) || ('' == mysql_error($link)))
3333
printf("[006] mysql_errno()/mysql_error should return some error\n");
3434

35-
if (!$res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; ', $link))
35+
if (!$res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link))
3636
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
3737

3838
var_dump(mysql_fetch_assoc($res));
3939
mysql_free_result($res);
4040

41-
if (!$res = mysql_query('SELECT "a" AS ""', $link))
41+
if (!$res = mysql_query("SELECT 'a' AS ''", $link))
4242
printf("[007a] [%d] %s\n", mysql_errno($link), mysql_error($link));
4343

4444
var_dump($tmp = mysql_fetch_assoc($res));
4545
var_dump($tmp[""]);
4646
mysql_free_result($res);
4747

48-
if (false !== ($res = mysql_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link)))
48+
if (false !== ($res = mysql_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link)))
4949
printf("[008] [%d] %s\n", mysql_errno($link), mysql_error($link));
5050

5151
if (mysql_query('DROP PROCEDURE IF EXISTS p', $link)) {

ext/mysql/tests/mysql_unbuffered_query.phpt

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,19 @@ if (NULL !== ($tmp = @mysql_unbuffered_query("SELECT 1 AS a", $link, "foo")))
2323
if (false !== ($tmp = mysql_unbuffered_query('THIS IS NOT SQL', $link)))
2424
printf("[003] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
2525

26-
if (false !== ($tmp = mysql_unbuffered_query('SELECT "this is sql but with backslash g"\g', $link)))
26+
if (false !== ($tmp = mysql_unbuffered_query("SELECT 'this is sql but with backslash g'\g", $link)))
2727
printf("[004] Expecting boolean/false, got %s/%s\n", gettype($tmp), $tmp);
2828

2929
if ((0 === mysql_errno($link)) || ('' == mysql_error($link)))
3030
printf("[005] mysql_errno()/mysql_error should return some error\n");
3131

32-
if (!$res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; ', $link))
32+
if (!$res = mysql_unbuffered_query("SELECT 'this is sql but with semicolon' AS valid ; ", $link))
3333
printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
3434

3535
var_dump(mysql_fetch_assoc($res));
3636
mysql_free_result($res);
3737

38-
if (false !== ($res = mysql_unbuffered_query('SELECT "this is sql but with semicolon" AS valid ; SHOW VARIABLES', $link)))
38+
if (false !== ($res = mysql_unbuffered_query("SELECT 'this is sql but with semicolon' AS valid ; SHOW VARIABLES", $link)))
3939
printf("[007] [%d] %s\n", mysql_errno($link), mysql_error($link));
4040

4141
if (mysql_unbuffered_query('DROP PROCEDURE IF EXISTS p', $link)) {

ext/mysql/tests/skipif.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
2-
require_once('connect.inc');
32
if (!extension_loaded("mysql")) {
43
die('skip mysql extension not available');
54
}
5+
require_once('connect.inc');
66
?>

ext/mysql/tests/table.inc

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (!mysql_query('CREATE TABLE test(id INT, label CHAR(1), PRIMARY KEY(id)) ENGI
1818
exit(1);
1919
}
2020

21-
if (!mysql_query('INSERT INTO test(id, label) VALUES (1, "a"), (2, "b"), (3, "c"), (4, "d"), (5, "e"), (6, "f")', $link)) {
21+
if (!mysql_query("INSERT INTO test(id, label) VALUES (1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f')", $link)) {
2222
printf("[%d] %s\n", mysql_errno($link), mysql_error($link));
2323
}
2424
?>

0 commit comments

Comments
 (0)