[Mono-bugs] [Bug 589482] New: DataTable.Clone loses the AutoIncrement of Columns of type Decimal

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Mar 18 14:58:54 EDT 2010


http://bugzilla.novell.com/show_bug.cgi?id=589482

http://bugzilla.novell.com/show_bug.cgi?id=589482#c0


           Summary: DataTable.Clone loses the AutoIncrement of Columns of
                    type Decimal
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.6.x
          Platform: Macintosh
        OS/Version: Mac OS X 10.6
            Status: NEW
          Severity: Critical
          Priority: P5 - None
         Component: Sys.Data
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: Dominique.Normand at cegedim.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_2; en-us)
AppleWebKit/531.22.7 (KHTML, like Gecko) Version/4.0.5 Safari/531.22.7

When cloning a DataTable that has decimal columns set to auto increment, the
cloned decimal columns will lose their auto increment property 

Reproducible: Always

Steps to Reproduce:
1. DataTable t1 = new DataTable();
2. DataColumn dc = t1.Columns.Add("c1", typeof(Decimal));
3. dc.AutoIncrement = true ;
4. DataTable t2 = t1.Clone() ;
5. if (! t2.Columns[0].AutoIncrement) throw new Exception("AutoIncrement not
copied"); 
Actual Results:  
The exception "AutoIncrement not Copied" will be thrown

Expected Results:  
The AutoIncrement property of the column should be copied and no exception
should be thrown

The bug is in the property DataType of the class DataColumn.

Here is the section that's causing the problem
//Check AutoIncrement status, make compatible datatype
if(AutoIncrement == true) {
    // we want to check that the datatype is supported?
    // TODO: Is this the same as CanAutoIncrement or was the omission of
Decimal intended?
    TypeCode typeCode = Type.GetTypeCode(value);

    if (typeCode != TypeCode.Int16 &&
        typeCode != TypeCode.Int32 &&
        typeCode != TypeCode.Int64) {
        AutoIncrement = false;
    }
}

Note that someone added a TODO comment instead of actually fixing the defect.

I think the correct code should be

//Check AutoIncrement status, make compatible datatype
if(AutoIncrement == true) {
    // we want to check that the datatype is supported?
    if (! CanAutoIncrement(value)) {
        AutoIncrement = false;
    }
}

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list