Skip to content

Commit 40868e4

Browse files
committed
Use table-based queries in gh20214 test for Firebird compat
Firebird requires SELECT ... FROM table syntax; bare SELECT 'val' AS col is not valid. Create a test table to make the test cross-driver compatible.
1 parent bb39596 commit 40868e4

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

ext/pdo/tests/gh20214.phpt

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,43 +14,46 @@ PDOTest::skip();
1414
if (getenv('REDIR_TEST_DIR') === false) putenv('REDIR_TEST_DIR='.__DIR__ . '/../../pdo/tests/');
1515
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
1616
$db = PDOTest::factory();
17+
18+
$db->exec('CREATE TABLE gh20214 (c1 VARCHAR(10), c2 VARCHAR(10))');
19+
$db->exec("INSERT INTO gh20214 VALUES ('v1', 'v2')");
20+
1721
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ);
1822

1923
// setFetchMode with FETCH_DEFAULT should use connection default (FETCH_OBJ)
20-
$stmt = $db->query("SELECT 'v1' AS c1, 'v2' AS c2");
24+
$stmt = $db->query('SELECT c1, c2 FROM gh20214');
2125
$stmt->setFetchMode(PDO::FETCH_DEFAULT);
2226
$row = $stmt->fetch();
2327
var_dump($row instanceof stdClass);
2428
var_dump($row->c1);
2529

2630
// fetch with FETCH_DEFAULT should also use connection default
27-
$stmt = $db->query("SELECT 'v1' AS c1, 'v2' AS c2");
31+
$stmt = $db->query('SELECT c1, c2 FROM gh20214');
2832
$row = $stmt->fetch(PDO::FETCH_DEFAULT);
2933
var_dump($row instanceof stdClass);
3034

3135
// fetchAll with FETCH_DEFAULT should also use connection default
32-
$stmt = $db->query("SELECT 'v1' AS c1, 'v2' AS c2");
36+
$stmt = $db->query('SELECT c1, c2 FROM gh20214');
3337
$rows = $stmt->fetchAll(PDO::FETCH_DEFAULT);
3438
var_dump($rows[0] instanceof stdClass);
3539

3640
// setFetchMode then fetch without argument
37-
$stmt = $db->query("SELECT 'v1' AS c1, 'v2' AS c2");
41+
$stmt = $db->query('SELECT c1, c2 FROM gh20214');
3842
$stmt->setFetchMode(PDO::FETCH_DEFAULT);
3943
$row = $stmt->fetch();
4044
var_dump($row instanceof stdClass);
4145

4246
// query() with FETCH_DEFAULT as second argument
4347
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_NUM);
44-
$stmt = $db->query("SELECT 'v1' AS c1, 'v2' AS c2", PDO::FETCH_DEFAULT);
48+
$stmt = $db->query('SELECT c1, c2 FROM gh20214', PDO::FETCH_DEFAULT);
4549
$row = $stmt->fetch();
4650
var_dump(is_array($row) && isset($row[0]));
47-
48-
// FETCH_DEFAULT with flags should preserve the flags
49-
$db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
50-
$stmt = $db->query("SELECT 'v1' AS c1, 'v2' AS c2");
51-
$stmt->setFetchMode(PDO::FETCH_DEFAULT | PDO::FETCH_GROUP);
52-
$rows = $stmt->fetchAll();
53-
var_dump(is_array($rows) && array_key_exists('v1', $rows));
51+
?>
52+
--CLEAN--
53+
<?php
54+
require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
55+
$db = PDOTest::factory();
56+
PDOTest::dropTableIfExists($db, "gh20214");
5457
?>
5558
--EXPECT--
5659
bool(true)
@@ -59,4 +62,3 @@ bool(true)
5962
bool(true)
6063
bool(true)
6164
bool(true)
62-
bool(true)

0 commit comments

Comments
 (0)