Foreign keys should relate to fields of the same type

Bug #861682 reported by Juan L. Negron
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
High
Unassigned
keystone (Ubuntu)
Fix Released
High
Brian Thomason
Oneiric
Fix Released
High
Brian Thomason

Bug Description

When using MySQL with InnoDB, the foreign key relations should have the same type.
The role table has a foreign key relation between it's service_id and the services.id field. Currently these two fields are of different types ( role.service_id is an integer while service.id is a varchar(255) which creates an error in MySQL/InnoDB.
I patched role.service_id to be a varchar(255) as well and that seems to fix the issue at hand at least for now.

Tags: patch
Revision history for this message
Juan L. Negron (negronjl) wrote :

Attaching patch

Revision history for this message
Juan L. Negron (negronjl) wrote :

I pushed the branch here for testing: lp:~negronjl/+junk/negronjl-keystone-foreign-key-patch

Changed in keystone (Ubuntu):
assignee: nobody → Brian Thomason (brian-thomason)
importance: Undecided → High
status: New → In Progress
Revision history for this message
Dustin Kirkland  (kirkland) wrote :

More properly, Juan has pushed to lp:~negronjl/keystone/861682 and proposed for merge:
 * https://code.launchpad.net/~negronjl/keystone/861682/+merge/77393

Revision history for this message
Dolph Mathews (dolph) wrote :

Both the Service and Role models use Integers for ID's & FK's:

    class Role(Base, KeystoneBase):
        id = Column(Integer, primary_key=True, autoincrement=True)
        service_id = Column(Integer, ForeignKey('services.id'))

    class Service(Base, KeystoneBase):
        id = Column(Integer, primary_key=True, autoincrement=True)

Source: https://github.com/openstack/keystone/blob/master/keystone/backends/sqlalchemy/models.py

Changed in keystone (Ubuntu Oneiric):
status: In Progress → Invalid
Dolph Mathews (dolph)
Changed in keystone:
status: New → Fix Committed
Changed in keystone (Ubuntu Oneiric):
status: Invalid → In Progress
Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "Foreign Key patch" of this bug report has been identified as being a patch. The ubuntu-reviewers team has been subscribed to the bug report so that they can review the patch. In the event that this is in fact not a patch you can resolve this situation by removing the tag 'patch' from the bug report and editing the attachment so that it is not flagged as a patch. Additionally, if you are member of the ubuntu-sponsors please also unsubscribe the team from this bug report.

[This is an automated message performed by a Launchpad user owned by Brian Murray. Please contact him regarding any issues with the action taken in this bug report.]

tags: added: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package keystone - 1.0~d4~20110909.1108-0ubuntu3

---------------
keystone (1.0~d4~20110909.1108-0ubuntu3) oneiric; urgency=low

  [Juan Negron]
  * Added debian/patches/foreign_key.patch: Fixed bug which attempted to to
    obtain a service_id by passing an Integer rather than a String to the
    Column function in models.py. (LP: #861682)

  [Brian Thomason]
  * Removed "|| true" from test execution in debian/rules as it was masking a
    failure. After investigating the failure further, it was found that two
    files were missing from the contrib/extensions/service/raxkey dir that were
    a part of trunk at the time. (LP: #861813)
    - added keystone/contrib/extensions/service/raxkey/extension.xml
    - added keystone/contrib/extensions/service/raxkey/extension.json
 -- Brian Thomason <email address hidden> Wed, 28 Sep 2011 15:30:19 -0400

Changed in keystone (Ubuntu Oneiric):
status: In Progress → Fix Released
Joe Savak (jsavak)
Changed in keystone:
importance: Undecided → High
Thierry Carrez (ttx)
Changed in keystone:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.