Support oci8 in TableGenerator #136

Closed
wants to merge 1 commit into
from

Projects

None yet

2 participants

Contributor
dpb587 commented Apr 28, 2012

Bug fix: yes
Feature addition: no
Backwards compatibility break: no
Build Status

This test was breaking when running under oci8 due to Oracle's deference to upper case column names. I realize Oracle has built-in sequences and TableGenerator is unnecessary, in theory, but it seemed like the class should work if possible. I see pgsql is in the same boat.

Tested with:

phpunit -c oci8.phpunit.xml.dist tests/Doctrine/Tests/DBAL/Functional/TableGeneratorTest.php

Before:

PHPUnit 3.5.13 by Sebastian Bergmann.

EE

Time: 0 seconds, Memory: 10.25Mb

There were 2 errors:

1) Doctrine\Tests\DBAL\Functional\TableGeneratorTest::testNextVal
Exception: [Doctrine\DBAL\DBALException] Error occured while generating ID with TableGenerator, aborted generation: Undefined index: sequence_value

2) Doctrine\Tests\DBAL\Functional\TableGeneratorTest::testNextValNotAffectedByOuterTransactions
Exception: [Doctrine\DBAL\DBALException] Error occured while generating ID with TableGenerator, aborted generation: Undefined index: sequence_value

After:

PHPUnit 3.5.13 by Sebastian Bergmann.

..

Time: 1 second, Memory: 10.25Mb

OK (2 tests, 5 assertions)
@beberlei beberlei commented on the diff May 4, 2012
lib/Doctrine/DBAL/Id/TableGenerator.php
@@ -119,20 +119,22 @@ public function nextValue($sequenceName)
$stmt = $this->conn->executeQuery($sql, array($sequenceName));
if ($row = $stmt->fetch()) {
- $value = $row['sequence_value'];
beberlei
beberlei May 4, 2012 Owner

I don't like this, since its depends on the default fetch value which could be assoc. Can you just use array_change_key_case($row, CASE_LOWER) ?

Owner
beberlei commented May 5, 2012

Committed the array_change_key_case() way under your author.

@beberlei beberlei closed this May 5, 2012
Contributor
dpb587 commented May 5, 2012

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment