Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

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

Merged
merged 3 commits into from Apr 16, 2013

Conversation

Projects
None yet
3 participants
Contributor

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?

Zend\Db\Metadata\Source\AbstractSource Undefined index notices
(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

Member

Freeaqingme commented Feb 8, 2013

@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 ;)

Contributor

ashawley commented Feb 8, 2013

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

Contributor

ashawley commented Feb 12, 2013

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

Contributor

ashawley commented Feb 18, 2013

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

Contributor

ashawley commented Feb 19, 2013

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

Member

Freeaqingme commented Mar 6, 2013

@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?

Contributor

ashawley commented Mar 7, 2013

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

Member

ralphschindler commented Mar 8, 2013

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

Contributor

ashawley commented Apr 8, 2013

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

ralphschindler added a commit that referenced this pull request Apr 16, 2013

PR #3719
Merge branch 'develop' of git://github.com/ashawley/zf2 into ashawley-master

ralphschindler added a commit that referenced this pull request Apr 16, 2013

PR #3719
Merge branch 'ashawley-master'

ralphschindler added a commit that referenced this pull request Apr 16, 2013

Forward #3719
Merge branch 'ashawley-master' into develop

@ralphschindler ralphschindler merged commit c2084aa into zendframework:develop Apr 16, 2013

1 check passed

default The Travis build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment