From ab360be101606c0a144c7c731700007cfa22841f Mon Sep 17 00:00:00 2001 From: Ville-Matti Riihikoski Date: Tue, 9 Jun 2015 08:39:07 +0300 Subject: [PATCH 1/3] Fix loading constraint data from Oracle --- src/Metadata/Source/OracleMetadata.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index d99f8a8bc4..57e3e9d676 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -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); From 2f856f2acd0312a926aaecd9ffb08bafeac3d472 Mon Sep 17 00:00:00 2001 From: Ville-Matti Riihikoski Date: Tue, 9 Jun 2015 08:39:07 +0300 Subject: [PATCH 2/3] Fix loading constraint data from Oracle --- src/Metadata/Source/OracleMetadata.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Metadata/Source/OracleMetadata.php b/src/Metadata/Source/OracleMetadata.php index d99f8a8bc4..57e3e9d676 100644 --- a/src/Metadata/Source/OracleMetadata.php +++ b/src/Metadata/Source/OracleMetadata.php @@ -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); From 515733280f51f568b6a950d5b9eb47260d188b2d Mon Sep 17 00:00:00 2001 From: Ville-Matti Riihikoski Date: Wed, 2 Sep 2015 13:11:42 +0300 Subject: [PATCH 3/3] Added test to get metadata constraints from Oracle database --- test/Metadata/Source/OracleMetadataTest.php | 55 +++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 test/Metadata/Source/OracleMetadataTest.php diff --git a/test/Metadata/Source/OracleMetadataTest.php b/test/Metadata/Source/OracleMetadataTest.php new file mode 100644 index 0000000000..5e2042b677 --- /dev/null +++ b/test/Metadata/Source/OracleMetadataTest.php @@ -0,0 +1,55 @@ +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 + ); + } +}