-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DBAL-2495] Optimize and improve parameter conversion in OCI8Statement
1. Reworked the parser syntax to use proper Oracle escaping syntax as '' instead of \'. 2. Moved valid tests to the Functional section to ensure correct SQL syntax and logic.
- Loading branch information
Showing
3 changed files
with
101 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
tests/Doctrine/Tests/DBAL/Functional/Driver/OCI8/StatementTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
<?php | ||
|
||
namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8; | ||
|
||
use Doctrine\DBAL\Driver\OCI8\Driver; | ||
use Doctrine\Tests\DbalFunctionalTestCase; | ||
|
||
class StatementTest extends DbalFunctionalTestCase | ||
{ | ||
protected function setUp() | ||
{ | ||
if (! extension_loaded('oci8')) { | ||
$this->markTestSkipped('oci8 is not installed.'); | ||
} | ||
|
||
parent::setUp(); | ||
|
||
if (! $this->_conn->getDriver() instanceof Driver) { | ||
$this->markTestSkipped('oci8 only test.'); | ||
} | ||
} | ||
|
||
/** | ||
* @dataProvider queryConversionProvider | ||
*/ | ||
public function testQueryConversion($query, array $params, array $expected) | ||
{ | ||
$this->assertEquals( | ||
$expected, | ||
$this->_conn->executeQuery($query, $params)->fetch() | ||
); | ||
} | ||
|
||
public static function queryConversionProvider() | ||
{ | ||
return array( | ||
'simple' => array( | ||
'SELECT ? COL1 FROM DUAL', | ||
array(1), | ||
array( | ||
'COL1' => 1, | ||
), | ||
), | ||
'literal-with-placeholder' => array( | ||
"SELECT '?' COL1, ? COL2 FROM DUAL", | ||
array(2), | ||
array( | ||
'COL1' => '?', | ||
'COL2' => 2, | ||
), | ||
), | ||
'literal-with-quotes' => array( | ||
"SELECT ? COL1, '?\"?''?' \"COL?\" FROM DUAL", | ||
array(3), | ||
array( | ||
'COL1' => 3, | ||
'COL?' => '?"?\'?', | ||
), | ||
), | ||
'placeholder-at-the-end' => array( | ||
'SELECT ? COL1 FROM DUAL WHERE 1 = ?', | ||
array(4, 1), | ||
array( | ||
'COL1' => 4, | ||
), | ||
), | ||
'multi-line-literal' => array( | ||
"SELECT 'Hello, | ||
World?!' COL1 FROM DUAL WHERE 1 = ?", | ||
array(1), | ||
array( | ||
'COL1' => 'Hello, | ||
World?!', | ||
), | ||
), | ||
'empty-literal' => array( | ||
"SELECT '' COL1 FROM DUAL", | ||
array(), | ||
array( | ||
'COL1' => '', | ||
), | ||
), | ||
); | ||
} | ||
} |