Watch, Follow, &
Connect with Us
Public Report
Report From: C#Builder/ECO/Core    [ Add a report in this area ]  
Report #:  33495   Status: Closed
size operation always returns 2 (after attribute->list conversion)
Project:  C#Builder Build #:  10.0.2288.42451
Version:    2005 Submitted By:   Dmitriy Nagirnyak
Report Type:  Basic functionality failure Date Reported:  9/5/2006 6:35:09 AM
Severity:    Commonly encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All platforms Internal Tracking #:   241822
Resolution: Fixed (Resolution Comments) Resolved in Build: : 11.0.2501.29663
Duplicate of:  None
Voting and Rating
Overall Rating: No Ratings Yet
0.00 out of 5
Total Votes: None
Description
Applaying ->size operation to a result of conversion an attribute of a domain object to a list will always return 2 (instead of 1) where the second value will be null.
Steps to Reproduce:
1. Prepare any class with simple property (ATTRIBUTE)
2. Evaluate OCL: "YourClass.allInstances->first.ATTRIBUTE->size"

Expected value is 1 but result is 2.
Workarounds
use as ->set operation after ->first operation to drop the 2-nd null value.
Attachment
None
Comments

Jonas Hogstrom at 9/5/2006 11:46:24 PM -
The bug occurs when a single attribute of an eco-object is converted to a list. The workaround trick is to let the list-conversion occur before navigating to the attribute:

YourClass.allInstances->first  // a single object
YourClass.allInstances->first.yourAttribute   // a single attribute
YourClass.allInstances->first.yourAttribute->size    // converts the single attribute to a list and counts the number of instances ==> 2   --  bug

YourClass.allInstances->first->asSet  // a list of a single object
YourClass.allInstances->first->asSet.yourAttribute  // a list of a single attribute
YourClass.allInstances->first->asSet.yourAttribute->size  // counts the number of instances in the list ==> 1

for a detailed discussion, read the news-thread http://tinyurl.com/jtwrg

Server Response from: ETNACODE01