Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to add parts to the project: FK constraint violation #129

Closed
apex- opened this issue Jan 7, 2012 · 8 comments
Closed

Unable to add parts to the project: FK constraint violation #129

apex- opened this issue Jan 7, 2012 · 8 comments

Comments

@apex-
Copy link

apex- commented Jan 7, 2012

When trying to add a part to the project I get the following SQL Exception

SQLSTATE[23503]: Foreign key violation: 7 ERROR: insert or update on table "projectpart" violates foreign key constraint "fk_b0b19336166d1f9c" DETAIL: Key (project_id)=(3) is not present in table "part".

Why is he trying to find the the project_id in table part?

This issue appies to nightly-20120106 and does NOT happen on a newly created database. Can't tell how to reproduce this right now.

@apex-
Copy link
Author

apex- commented Jan 7, 2012

Here is the backtrace of the Exception:

#0 /usr/share/php/Doctrine/DBAL/Statement.php(131): PDOStatement->execute(NULL)
#1 /usr/share/php/Doctrine/ORM/Persisters/BasicEntityPersister.php(237): Doctrine\DBAL\Statement->execute()
#2 /usr/share/php/Doctrine/ORM/UnitOfWork.php(726): Doctrine\ORM\Persisters\BasicEntityPersister->executeInserts()
#3 /usr/share/php/Doctrine/ORM/UnitOfWork.php(292): Doctrine\ORM\UnitOfWork->executeInserts(Object(Doctrine\ORM\Mapping\ClassMetadata))
#4 /usr/share/php/Doctrine/ORM/EntityManager.php(334): Doctrine\ORM\UnitOfWork->commit()
#5 /var/www/partkeepr/src/backend/de/RaumZeitLabor/PartKeepr/Project/ProjectService.php(49): Doctrine\ORM\EntityManager->flush()
#6 /var/www/partkeepr/src/backend/de/RaumZeitLabor/PartKeepr/Service/ServiceManager.php(82): de\RaumZeitLabor\PartKeepr\Project\ProjectService->update()
#7 /var/www/partkeepr/frontend/rest.php(54): de\RaumZeitLabor\PartKeepr\Service\ServiceManager::call()
#8 {main}

@Drachenkaetzchen
Copy link
Member

I'm not sure where this comes from. I just did a quick test on pgsql8, and it works for me. Also no project_id in the part table here.

Can you reproduce this on your nightly-20120106, or was this an one-timer?

@apex-
Copy link
Author

apex- commented Jan 7, 2012

Issue is caused by wrong entity relation in ProjectPart.php and has been fixed in the meantime

PartKeepr: Felicitus master * r1cf520f / src/backend/de/RaumZeitLabor/PartKeepr/Project/ProjectPart.php : Fixed wrong entity type for project parts - http://git.io/jId9vg

@apex-
Copy link
Author

apex- commented Jan 7, 2012

Affected databases can be fixed with the following SQL statement

ALTER TABLE projectpart DROP CONSTRAINT fk_b0b19336166d1f9c;

ALTER TABLE projectpart ADD CONSTRAINT fk_b0b19336166d1f9c
FOREIGN KEY (project_id) REFERENCES project(id);

@Drachenkaetzchen
Copy link
Member

I believe this can be closed now.

@Drachenkaetzchen
Copy link
Member

This is a problem within Doctrine and it is unfortunately not yet fixed. The upstream bug is http://www.doctrine-project.org/jira/browse/DDC-1586

@Drachenkaetzchen
Copy link
Member

Reminder sent to the doctrine devs, there's nothing left I can do. Moving to the next milestone and keeping open for tracking.

@Drachenkaetzchen
Copy link
Member

This is now fixed according to the doctrine developers: http://www.doctrine-project.org/jira/browse/DBAL-479

Please test, I'm closing this bug as I haven't been hit by it.

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

No branches or pull requests

2 participants