Bug 865394 - case_id 1 is referenced in test_case_components but does not exist
Summary: case_id 1 is referenced in test_case_components but does not exist
Keywords:
Status: CLOSED WONTFIX
Alias: None
Product: TCMS
Classification: Other
Component: Database
Version: Devel
Hardware: Unspecified
OS: Unspecified
unspecified
low
Target Milestone: ---
: ---
Assignee: jianchen
QA Contact: tools-bugs
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-10-11 10:37 UTC by Chris Ward
Modified: 2012-11-02 11:50 UTC (History)
7 users (show)

Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2012-11-02 11:50:24 UTC
Embargoed:


Attachments (Terms of Use)

Description Chris Ward 2012-10-11 10:37:20 UTC
Description of problem:

According to .test_case_components, there should be a case_id 1


In [5]: e("SELECT component_id FROM Testopia.test_case_components WHERE case_id = 1")

In [6]: for a in f(): print a
(23005,)
(23006,)
(23007,)



But there isn't...


In [11]: e("SELECT True FROM Testopia.test_cases WHERE case_id = 1")

In [12]: for a in f(): print a
# None

Comment 1 jianchen 2012-10-12 03:05:01 UTC
A many-to-many relationship between case and component. test_case_components is a intermediary table which manage many-to-many relationships. Case(case_id = 1) was delete but the test_case_component records retain.

Comment 2 Chris Ward 2012-10-12 08:30:38 UTC
When a case_id (eg, 1) is deleted, shouldn't test_case_component map be updated as well to remove the relationship which no longer exists? (activity history should track the fact that it did exist in the past...and that it was removed)

Many-to-Many relationships should only map to existing data, no? 

Or is a mapping like this valid, where items are mapped that don't exist?

Doesn't make sense to me. I would think for sure when case_id was removed, all current references to case_id 1 should be removed as well... since there will be no reference to case_id 1 anymore...  or better yet, case_id should not have been removed, but rather set to 'disabled=True', no? If that happened, this problem of missing references wouldn't exist.


Anyway, i believe either case_id 1 should be restored and set to disabled or all references to it should be removed. 

Otherwise, how are we supposed to interpret mappings to things that don't exist?

Comment 3 jianchen 2012-10-15 02:59:07 UTC
(In reply to comment #2)
> When a case_id (eg, 1) is deleted, shouldn't test_case_component map be
> updated as well to remove the relationship which no longer exists? (activity
> history should track the fact that it did exist in the past...and that it
> was removed)
> 
> Many-to-Many relationships should only map to existing data, no? 
> 
> Or is a mapping like this valid, where items are mapped that don't exist?
> 
> Doesn't make sense to me. I would think for sure when case_id was removed,
> all current references to case_id 1 should be removed as well... since there
> will be no reference to case_id 1 anymore...  or better yet, case_id should
> not have been removed, but rather set to 'disabled=True', no? If that
> happened, this problem of missing references wouldn't exist.
> 
> 
> Anyway, i believe either case_id 1 should be restored and set to disabled or
> all references to it should be removed. 
> 
> Otherwise, how are we supposed to interpret mappings to things that don't
> exist?
testcase (eg, case_id 1) is the history record which migrate from testopia to TCMS.
In TCMS, case was removed, all current references to case (eg, component) was removed as well. 
You can write a new case and add component, if testcase delete, intermediary table(eg, test_case_components) record will delete.


Note You need to log in before you can comment on or make changes to this bug.