2005-02-25 Atsushi Enomoto <atsushi@ximian.com>
authorAtsushi Eno <atsushieno@gmail.com>
Fri, 25 Feb 2005 10:06:19 +0000 (10:06 -0000)
committerAtsushi Eno <atsushieno@gmail.com>
Fri, 25 Feb 2005 10:06:19 +0000 (10:06 -0000)
* DataColumn.cs : setting negative value on MaxLength of SimpleContent
  column is still valid.

* DataColumnTest.cs : added testcase for setting negative value on
  DataColumn whose mapping is SimpleContent.

svn path=/trunk/mcs/; revision=41186

mcs/class/System.Data/System.Data/ChangeLog
mcs/class/System.Data/System.Data/DataColumn.cs
mcs/class/System.Data/Test/System.Data/ChangeLog
mcs/class/System.Data/Test/System.Data/DataColumnTest.cs

index 0ef1df538cacc0439545848cbbb32a5727e048be..fa155e408f7c48f8855373bdf02b20081fc1a753 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DataColumn.cs : setting negative value on MaxLength of SimpleContent
+         column is still valid.
+
 2005-02-15  Atsushi Enomoto  <atsushi@ximian.com>
 
        * XmlSchemaWriter.cs : new file for outputting XmlSchema.
index a2ece9d0c9e97681d97b87401fba8dc4aaa48c65..29b8f305f07ab7578c198b9dceb4823ad7764997 100644 (file)
@@ -481,7 +481,8 @@ namespace System.Data {
                                return maxLength;
                        }
                        set {
-                               if (_columnMapping == MappingType.SimpleContent)
+                               if (value >= 0 &&
+                                       _columnMapping == MappingType.SimpleContent)
                                        throw new ArgumentException (String.Format ("Cannot set MaxLength property on '{0}' column which is mapped to SimpleContent.", ColumnName));
                                //only applies to string columns
                                maxLength = value;
index 3dce72cb0d78e247eddd695ec0b32649a4dcfaca..f90332dfe7c8527b54c7af26f4185fdb27457c2e 100644 (file)
@@ -1,3 +1,8 @@
+2005-02-25  Atsushi Enomoto  <atsushi@ximian.com>
+
+       * DataColumnTest.cs : added testcase for setting negative value on
+         DataColumn whose mapping is SimpleContent.
+
 2005-02-15  Atsushi Enomoto  <atsushi@ximian.com>
 
        * DataSetAssertion.cs : don't exclude those attribute whose namespace
index 64b388ad1ef9ccf206eecef566bda68c2c901f78..ed06aeaebc74c0c92677f79c445593a63d8d744c 100644 (file)
@@ -553,8 +553,9 @@ namespace MonoTests.System.Data
 
                [Test]
                [ExpectedException (typeof (ArgumentException))]
-               public void SetMaxColumn ()
+               public void SetMaxLengthException ()
                {
+                       // Setting MaxLength on SimpleContent -> exception
                        DataSet ds = new DataSet("Example");
                        ds.Tables.Add("MyType");
                        ds.Tables["MyType"].Columns.Add(new DataColumn("Desc", 
@@ -562,6 +563,17 @@ namespace MonoTests.System.Data
                        ds.Tables["MyType"].Columns["Desc"].MaxLength = 32;
                }
 
+               [Test]
+               public void SetMaxLengthNegativeValue ()
+               {
+                       // however setting MaxLength on SimpleContent is OK
+                       DataSet ds = new DataSet ("Example");
+                       ds.Tables.Add ("MyType");
+                       ds.Tables ["MyType"].Columns.Add (
+                               new DataColumn ("Desc", typeof (string), "", MappingType.SimpleContent));
+                       ds.Tables ["MyType"].Columns ["Desc"].MaxLength = -1;
+               }
+
                [Test]
                 public void AdditionToConstraintCollectionTest()
                 {