Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Commit

Permalink
Merge pull request #34 from vixriihi/master
Browse files Browse the repository at this point in the history
Fix for fetching constraint data from Oracle
  • Loading branch information
weierophinney committed Sep 22, 2015
2 parents ce05c93 + d205187 commit d0e9754
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Metadata/Source/OracleMetadata.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,14 +124,14 @@ protected function loadConstraintData($table, $schema)
AND cc2.position = cc1.position
WHERE
ac.owner = :schema AND ac.table_name = :table
ac.owner = :ownername AND ac.table_name = :tablename
ORDER BY ac.constraint_name;
ORDER BY ac.constraint_name
';

$parameters = [
':schema' => $schema,
':table' => $table
':ownername' => $schema,
':tablename' => $table
];

$results = $this->adapter->query($sql)->execute($parameters);
Expand Down
55 changes: 55 additions & 0 deletions test/Metadata/Source/OracleMetadataTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace ZendTest\Db\Metadata\Source;

use Zend\Db\Adapter\Adapter;
use Zend\Db\Metadata\Source\OracleMetadata;
use ZendTest\Db\Adapter\Driver\Oci8\AbstractIntegrationTest;

/**
* @requires extension oci8
*/
class OracleMetadataTest extends AbstractIntegrationTest
{
/**
* @var OracleMetadata
*/
protected $metadata;

/**
* @var Adapter
*/
protected $adapter;

/**
* Sets up the fixture, for example, opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
if (!extension_loaded('oci8')) {
$this->markTestSkipped('I cannot test without the oci8 extension');
}
parent::setUp();
$this->variables['driver'] = 'OCI8';
$this->adapter = new Adapter($this->variables);
$this->metadata = new OracleMetadata($this->adapter);
}

public function testGetConstraints()
{
$constraints = $this->metadata->getConstraints(null, 'main');
$this->assertCount(0, $constraints);
$this->assertContainsOnlyInstancesOf(
'Zend\Db\Metadata\Object\ConstraintObject',
$constraints
);
}
}

0 comments on commit d0e9754

Please sign in to comment.