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

Zend\Db\Metadata\Source\AbstractSource Notice: Undefined index #3719

Merged
merged 3 commits into from Apr 16, 2013
Merged

Conversation

ashawley
Copy link
Contributor

@ashawley ashawley commented Feb 7, 2013

I'm using my own Metadata source, but I'm pretty confident this occurs for the existing sources (Mysql, Postgresql, Sqlserver, ...).

$metadata = new Zend\Db\Metadata\Metadata($adapter);
$constraints = $metadata->getConstraints('TABLE', 'SCHEMA');
foreach($constraints as $constraint) {
    $constraintKeys = $metadata->getConstraintKeys(
        $constraint->getName(),
        'TABLE', 'SCHEMA'
    );
}

Produces the following errors:

Notice: Undefined index: constraint_references in library/Zend/Db/Metadata/Source/AbstractSource.php on line 393
Notice: Undefined index: constraint_keys in library/Zend/Db/Metadata/Source/AbstractSource.php on line 400

Note that after this fixing this error I run into the next one:

 Fatal error: Class 'Zend\Db\Metadata\Object\ConstraintKeyObject' not found on line 398

Was that class just never committed?

(AbstractSource::getConstraintKeys): Add call to
child::loadConstraintReferences() and child::loadConstraintDataKeys()
to avoid triggering PHP notices for constraint_references and
constraint_keys
@ghost ghost assigned ralphschindler Feb 8, 2013
@Freeaqingme
Copy link
Member

@ashawley Could you please attach a unit test that reproduces this behavior?

@ralphschindler I'm assigning this issue to you. You may know a little more about the referenced missing ConstraintKeyObject class.
Edit: You already were ;)

@ashawley
Copy link
Contributor Author

ashawley commented Feb 8, 2013

@Freeaqingme I would have attached a unit test but didn't see any unit tests for Zend\Db\MetaData.

@ashawley
Copy link
Contributor Author

Let me know if there really are no unit tests for Zend\Db\Metadata. I assumed TDD was done for all modules in ZF2. I wondered if someone forgot to commit the unit tests since the ConstraintKeyObject class is also missing.

If there are no unit tests for Zend\Db\Metadata, I'd be willing to volunteer to write them.

@ashawley ashawley closed this Feb 18, 2013
@ashawley ashawley reopened this Feb 18, 2013
@ashawley
Copy link
Contributor Author

There's a unit test using a Sqlite DB adapter. Hope that helps.

@ashawley
Copy link
Contributor Author

The Travis builds that are are broken are for unit tests unrelated to these -- Zend\Captcha\Image.

@Freeaqingme
Copy link
Member

@ashawley Thank you for providing unit tests with this issue. That's really helpful. There are two minor issues that come to mind still: Could you please add some docblocks to the two methods you introduce (I'm seeing some other methods in that class don't have them either - feel free to update those as well =) )? Also, could you perhaps give your unit tests a @group annotation that refers to this issue? That may help others in the future to find out what issue these tests actually test for.

I'm not enough into Zend\Db to be comfortable merging this, @ralphschindler could you take upon reviewing this issue?

@ashawley
Copy link
Contributor Author

ashawley commented Mar 7, 2013

@Freeaqingme I've added docblocks and a group annotation. Thanks for reviewing my changes.

@ralphschindler
Copy link
Member

I've got this on my list for early next week as I'll be doing Db integration testing.

@ashawley
Copy link
Contributor Author

ashawley commented Apr 8, 2013

Just saw that Zend\Db\Metadata\Object\ConstraintKeyObject was deleted last year in b9b7875e. I'm not sure why.

ralphschindler pushed a commit that referenced this pull request Apr 16, 2013
Merge branch 'develop' of git://github.com/ashawley/zf2 into ashawley-master
ralphschindler pushed a commit that referenced this pull request Apr 16, 2013
Merge branch 'ashawley-master'
ralphschindler pushed a commit that referenced this pull request Apr 16, 2013
Merge branch 'ashawley-master' into develop
@ralphschindler ralphschindler merged commit c2084aa into zendframework:develop Apr 16, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants