Foreign keys should relate to fields of the same type

Bug #861682 reported by Juan L. Negron on 2011-09-28
14
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
High
Unassigned
keystone (Ubuntu)
High
Brian Thomason
Oneiric
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.

Juan L. Negron (negronjl) wrote :

Attaching patch

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

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) on 2011-09-28
Changed in keystone:
status: New → Fix Committed
Changed in keystone (Ubuntu Oneiric):
status: Invalid → In Progress

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
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) on 2011-10-14
Changed in keystone:
importance: Undecided → High
Thierry Carrez (ttx) on 2011-11-09
Changed in keystone:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers