Bug 292239

Summary: SQL code indexes wrong field for foreign key
Product: [Applications] umbrello Reporter: Mario Epp <computer>
Component: generalAssignee: Umbrello Development Group <umbrello-devel>
Status: RESOLVED FIXED    
Severity: normal CC: ralf.habacker
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed In: 2.26.90 (KDE Applications 18.11.90)
Attachments: Wrong or incomplete code example generated by Umbrello for MySQL.
xmi test case

Description Mario Epp 2012-01-22 23:31:34 UTC
Created attachment 68103 [details]
Wrong or incomplete code example generated by Umbrello for MySQL.

Version:           unspecified (using KDE 4.6.5) 
OS:                Linux

The MySQL code generator appears to place the field name of the referenced table to index in the local table, instead of the foreign key field name of the local table.

In the attached file of MySQL code generetad I have manually corrected the SQL in order to generate the corresponding table.

Reproducible: Always

Steps to Reproduce:
Define 2 entities and define a foreign key, then generate the corresponding the MySQL code.


Expected Results:  
The code should create an index on the foreign key field in the local table.

OS: Linux (x86_64) release 2.6.37.6-0.11-desktop
Compiler: gcc
Comment 1 Andrew Crouthamel 2018-11-06 15:10:50 UTC
Dear Bug Submitter,

This bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? I am setting the status to NEEDSINFO pending your response, please change the Status back to REPORTED when you respond.

Thank you for helping us make KDE software even better for everyone!
Comment 2 Andrew Crouthamel 2018-11-18 03:21:36 UTC
Dear Bug Submitter,

This is a reminder that this bug has been stagnant for a long time. Could you help us out and re-test if the bug is valid in the latest version? This bug will be moved back to REPORTED Status for manual review later, which may take a while. If you are able to, please lend us a hand.

Thank you for helping us make KDE software even better for everyone!
Comment 3 Ralf Habacker 2018-11-19 23:38:54 UTC
Created attachment 116414 [details]
xmi test case
Comment 4 Ralf Habacker 2018-11-20 00:02:29 UTC
The reported issue could be reproduced with current version. Generating mysql code returns:

------------ neue_entitaet.sql ---------------

CREATE TABLE neue_entitaet (
    neues_feld  NOT NULL 
);

CREATE INDEX neue_entitaet_1_feld_index  ON neue_entitaet(feld);

-- 
ALTER TABLE neue_entitaet ADD CONSTRAINT neue_fremschluessel_einschraenkung FOREIGN KEY (neues_feld) REFERENCES neue_entitaet_1(feld) ON UPDATE NO ACTION ON DELETE NO ACTION;


------------ neue_entitaet_1.sql ---------------

CREATE TABLE neue_entitaet_1 (
    feld int NOT NULL 
);

The incorrectly generated line is

CREATE INDEX neue_entitaet_1_feld_index  ON neue_entitaet(feld);

because 'feld' is not a column of table 'neue_entitaet'
Comment 5 Ralf Habacker 2018-11-20 00:28:31 UTC
Git commit b1303405b534ee56ec37ba33ecf2e4fa83d9a383 by Ralf Habacker.
Committed on 20/11/2018 at 00:27.
Pushed by habacker into branch 'Applications/18.12'.

Fix 'SQL code indexes wrong field for foreign key'
FIXED-IN:2.26.90 (KDE Applications 18.11.90)

M  +3    -3    umbrello/codegenerators/sql/mysqlwriter.cpp
M  +1    -1    umbrello/codegenerators/sql/sqlwriter.cpp

https://commits.kde.org/umbrello/b1303405b534ee56ec37ba33ecf2e4fa83d9a383