2002-10-28 Ville Palo <vi64pa@koti.soon.fi>
authorVille Palo <ville@mono-cvs.ximian.com>
Mon, 28 Oct 2002 16:43:12 +0000 (16:43 -0000)
committerVille Palo <ville@mono-cvs.ximian.com>
Mon, 28 Oct 2002 16:43:12 +0000 (16:43 -0000)
* System.Data.SqlTypes/SqlBinary.cs:
* System.Data.SqlTypes/SqlBoolean.cs:
* System.Data.SqlTypes/SqlByte.cs:
* System.Data.SqlTypes/SqlDateTime.cs:
* System.Data.SqlTypes/SqlDecimal.cs:
* System.Data.SqlTypes/SqlDouble.cs:
* System.Data.SqlTypes/SqlDecimal.cs:
* System.Data.SqlTypes/SqlDouble.cs:
* System.Data.SqlTypes/SqlGuid.cs:
* System.Data.SqlTypes/SqlInt16.cs:
* System.Data.SqlTypes/SqlInt32.cs:
* System.Data.SqlTypes/SqlInt64.cs:
* System.Data.SqlTypes/Money.cs:
* System.Data.SqlTypes/SqlSingle.cs:
* System.Data.SqlTypes/SqlString.cs:
* System.Data.SqlTypes/SqlSingle.cs: Fixed internal loop bugs and
some other minor fixes. Now all of the test suites work.

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

14 files changed:
mcs/class/System.Data/ChangeLog
mcs/class/System.Data/System.Data.SqlTypes/SqlBinary.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlBoolean.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlByte.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlDateTime.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlDecimal.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlDouble.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlGuid.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlInt16.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlInt32.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlInt64.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlMoney.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlSingle.cs
mcs/class/System.Data/System.Data.SqlTypes/SqlString.cs

index 6e7b38083e21a70c18ee2c435b70e5d4ce0ccd05..8e05d26ef009dcd44275a8b83df50124c045a2e6 100644 (file)
@@ -1,3 +1,23 @@
+2002-10-28  Ville Palo <vi64pa@koti.soon.fi>
+
+       * System.Data.SqlTypes/SqlBinary.cs:
+       * System.Data.SqlTypes/SqlBoolean.cs:
+       * System.Data.SqlTypes/SqlByte.cs:
+       * System.Data.SqlTypes/SqlDateTime.cs:
+       * System.Data.SqlTypes/SqlDecimal.cs:
+       * System.Data.SqlTypes/SqlDouble.cs:
+       * System.Data.SqlTypes/SqlDecimal.cs:
+       * System.Data.SqlTypes/SqlDouble.cs:
+       * System.Data.SqlTypes/SqlGuid.cs:
+       * System.Data.SqlTypes/SqlInt16.cs:
+       * System.Data.SqlTypes/SqlInt32.cs:
+       * System.Data.SqlTypes/SqlInt64.cs:
+       * System.Data.SqlTypes/Money.cs:
+       * System.Data.SqlTypes/SqlSingle.cs:
+       * System.Data.SqlTypes/SqlString.cs:
+       * System.Data.SqlTypes/SqlSingle.cs: Fixed internal loop bugs and
+       some other minor fixes.
+
 2002-10-27  Rodrigo Moya <rodrigo@ximian.com>
 
        * System.Data.OleDb/OleDbDataAdapter.cs (Fill, FillSchema,
index 47a7b2b43ff4d94bbdb2f9423a7a6896b28f16f3..f989d00172462edb476a367c6efbda1a24e9286c 100644 (file)
@@ -23,6 +23,7 @@ namespace System.Data.SqlTypes
                #region Fields
 
                byte[] value;
+               private bool notNull;
 
                public static readonly SqlBinary Null;
 
@@ -33,6 +34,7 @@ namespace System.Data.SqlTypes
                public SqlBinary (byte[] value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                #endregion
@@ -40,7 +42,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull {
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public byte this[int index] {
index 4ffa919676c49d71b041bb8ebc43414b1ca738e0..75adfa7025716aab91da8ba46c10b0bb142502ff 100644 (file)
@@ -25,6 +25,9 @@ namespace System.Data.SqlTypes
                #region Fields
 
                byte value;
+               
+               // default is false
+               private bool notNull;
 
                public static readonly SqlBoolean False = new SqlBoolean (false);
                public static readonly SqlBoolean Null;
@@ -39,11 +42,13 @@ namespace System.Data.SqlTypes
                public SqlBoolean (bool value) 
                {
                        this.value = (byte) (value ? 1 : 0);
+                       notNull = true;
                }
 
                public SqlBoolean (int value) 
                {
                        this.value = (byte) (value != 0 ? 1 : 0);
+                       notNull = true;
                }
 
                #endregion // Constructors
@@ -53,7 +58,7 @@ namespace System.Data.SqlTypes
                public byte ByteValue {
                        get {
                                if (this.IsNull)
-                                       throw new SqlNullValueException( "The property is set to null.");
+                                       throw new SqlNullValueException(Locale.GetText("The property is set to null."));
                                else
                                        return value;
                        }
@@ -69,7 +74,9 @@ namespace System.Data.SqlTypes
                }
 
                public bool IsNull {
-                       get { return (bool) (this == Null); }
+                       get { 
+                               return !notNull;
+                       }
                }
 
                public bool IsTrue {
@@ -84,7 +91,7 @@ namespace System.Data.SqlTypes
                public bool Value {
                        get { 
                                if (this.IsNull)
-                                       throw new SqlNullValueException( "The property is set to null.");
+                                       throw new SqlNullValueException(Locale.GetText("The property is set to null."));
                                else
                                        return this.IsTrue;
                        }
@@ -194,7 +201,7 @@ namespace System.Data.SqlTypes
                public SqlString ToSqlString() 
                {
                        if (this.IsNull)
-                               throw new SqlNullValueException ("The value is null");
+                               return new SqlString ("Null");
                        if (this.IsTrue)
                                return new SqlString ("True");
                        else
@@ -204,7 +211,7 @@ namespace System.Data.SqlTypes
                public override string ToString() 
                {
                        if (this.IsNull)
-                               throw new SqlNullValueException ("The value is null");
+                               return "Null";
                        if (this.IsTrue)
                                return "True";
                        else
index 8a09b3bebe5ebe38a139c349e8715553cf2028c3..05b74534fb9980161305d793925d8a1c72e99405 100644 (file)
@@ -17,6 +17,8 @@ namespace System.Data.SqlTypes
                #region Fields
 
                byte value;
+               private bool notNull;
+
                public static readonly SqlByte MaxValue = new SqlByte (0xff);
                public static readonly SqlByte MinValue = new SqlByte (0);
                public static readonly SqlByte Null;
@@ -29,6 +31,7 @@ namespace System.Data.SqlTypes
                public SqlByte (byte value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                #endregion
@@ -36,7 +39,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull {
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public byte Value { 
@@ -200,7 +203,7 @@ namespace System.Data.SqlTypes
                public override string ToString ()
                {
                        if (this.IsNull)
-                               return String.Empty;
+                               return "Null";
                        else
                                return value.ToString ();
                }
index ca53e30015333bf6c92fbfc251277ef8bd6212f3..0f5b1bfa27759dfb2fd548b70171da48aa5131b7 100644 (file)
@@ -16,6 +16,7 @@ namespace System.Data.SqlTypes
        {
                #region Fields
                private DateTime value;
+               private bool notNull;
 
                public static readonly SqlDateTime MaxValue = new SqlDateTime (9999,12,31);
                public static readonly SqlDateTime MinValue = new SqlDateTime (1753,1,1);
@@ -31,34 +32,40 @@ namespace System.Data.SqlTypes
                public SqlDateTime (DateTime value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                [MonoTODO]
                public SqlDateTime (int dayTicks, int timeTicks) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                public SqlDateTime (int year, int month, int day) 
                {
                        this.value = new DateTime (year, month, day);
+                       notNull = true;
                }
 
                public SqlDateTime (int year, int month, int day, int hour, int minute, int second) 
                {
                        this.value = new DateTime (year, month, day, hour, minute, second);
+                       notNull = true;
                }
 
                [MonoTODO]
                public SqlDateTime (int year, int month, int day, int hour, int minute, int second, double millisecond) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                [MonoTODO]
                public SqlDateTime (int year, int month, int day, int hour, int minute, int second, int bilisecond) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                #endregion
@@ -71,7 +78,7 @@ namespace System.Data.SqlTypes
                }
 
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                [MonoTODO]
index 93017993f35079ac74e7ecb1e5b98870e38a509f..c996eb67b7f23453c37e91549b62802b473a3e62 100644 (file)
@@ -21,6 +21,8 @@ namespace System.Data.SqlTypes
                byte scale;
                bool positive;
 
+               private bool notNull;
+
                // borrowed from System.Decimal
                const int SCALE_SHIFT = 16;
                const int SIGN_SHIFT = 31;
@@ -52,6 +54,7 @@ namespace System.Data.SqlTypes
                        this.value[1] = binData[1];
                        this.value[2] = binData[2];
                        this.value[3] = 0;
+                       notNull = true;
                }
 
                public SqlDecimal (double value) : this ((decimal)value) { }
@@ -70,6 +73,7 @@ namespace System.Data.SqlTypes
                        this.value[1] = data2;
                        this.value[2] = data3;
                        this.value[3] = data4;
+                       notNull = true;
                }
 
                #endregion
@@ -91,7 +95,7 @@ namespace System.Data.SqlTypes
                }
 
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public bool IsPositive { 
index 6206879ac4bc0dbf97aec13a2e2d93806d9d821f..028ff1120eb3c5300c8bc189496d74abd0e9368b 100644 (file)
@@ -17,6 +17,8 @@ namespace System.Data.SqlTypes
                #region Fields
                double value;
 
+               private bool notNull;
+
                public static readonly SqlDouble MaxValue = new SqlDouble (1.7976931348623157e308);
                public static readonly SqlDouble MinValue = new SqlDouble (-1.7976931348623157e308);
                public static readonly SqlDouble Null;
@@ -29,6 +31,7 @@ namespace System.Data.SqlTypes
                public SqlDouble (double value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                #endregion
@@ -36,7 +39,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public double Value { 
@@ -89,7 +92,9 @@ namespace System.Data.SqlTypes
 
                public override int GetHashCode ()
                {
-                       return (int)value;
+                       long LongValue = (long)value;
+                       return (int)(LongValue ^ (LongValue >> 32));
+                       
                }
 
                public static SqlBoolean GreaterThan (SqlDouble x, SqlDouble y)
index 5c020c57127b5dfcf180f4d9508286b462f53f8c..d2ed8d5edb3aa3979b31aade007e5de626ef2c38 100644 (file)
@@ -16,7 +16,9 @@ namespace System.Data.SqlTypes
        {
                #region Fields
 
-               Guid value;
+               Guid value;
+
+               private bool notNull;
 
                public static readonly SqlGuid Null;
 
@@ -27,21 +29,25 @@ namespace System.Data.SqlTypes
                public SqlGuid (byte[] value) 
                {
                        this.value = new Guid (value);
+                       notNull = true;
                }
 
                public SqlGuid (Guid g) 
                {
                        this.value = g;
+                       notNull = true;
                }
 
                public SqlGuid (string s) 
                {
                        this.value = new Guid (s);
+                       notNull = true;
                }
 
                public SqlGuid (int a, short b, short c, byte d, byte e, byte f, byte g, byte h, byte i, byte j, byte k) 
                {
                        this.value = new Guid (a, b, c, d, e, f, g, h, i, j, k);
+                       notNull = true;
                }
 
                #endregion
@@ -49,7 +55,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull {
-                       get { return (bool) (this == SqlGuid.Null); }
+                       get { return !notNull; }
                }
 
                public Guid Value { 
index 2dcf9bee05d2cda77167be408e8c99736d811bc1..a2063710f77a4fe30c0175392399f5558b608166 100644 (file)
@@ -17,6 +17,7 @@ namespace System.Data.SqlTypes
                #region Fields
 
                short value;
+               private bool notNull;
 
                public static readonly SqlInt16 MaxValue = new SqlInt16 (32767);
                public static readonly SqlInt16 MinValue = new SqlInt16 (-32768);
@@ -30,6 +31,7 @@ namespace System.Data.SqlTypes
                public SqlInt16 (short value) 
                {
                        this.value = value;
+                       notNull = true;;
                }
 
                #endregion
@@ -37,7 +39,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public short Value { 
@@ -201,7 +203,7 @@ namespace System.Data.SqlTypes
                public override string ToString ()
                {
                        if (this.IsNull)
-                               return String.Empty;
+                               return "Null";
                        else
                                return value.ToString ();
                }
@@ -223,7 +225,7 @@ namespace System.Data.SqlTypes
 
                public static SqlInt16 operator | (SqlInt16 x, SqlInt16 y)
                {
-                       return new SqlInt16 ((short) (x | y));
+                       return new SqlInt16 ((short) (x.Value | y.Value));
                }
 
                public static SqlInt16 operator / (SqlInt16 x, SqlInt16 y)
index 2a048227803729687b8c4e25f3cee63ea1c4631c..41f8c951593e3988f3c72de0b13636068d34c712 100644 (file)
@@ -25,6 +25,7 @@ namespace System.Data.SqlTypes
                #region Fields
 
                int value;
+               private bool notNull;
 
                public static readonly SqlInt32 MaxValue = new SqlInt32 (2147483647);
                public static readonly SqlInt32 MinValue = new SqlInt32 (-2147483648);
@@ -38,6 +39,7 @@ namespace System.Data.SqlTypes
                public SqlInt32(int value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                #endregion
@@ -45,7 +47,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull {
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public int Value {
@@ -209,7 +211,7 @@ namespace System.Data.SqlTypes
                public override string ToString() 
                {
                        if (this.IsNull)
-                               return String.Empty;
+                               return "Null";
                        else
                                return value.ToString ();
                }
index c15e1cc240568d9ddc422e907fe4d4f9db65158a..f5e44ee63c6607fb1d1fe52d7294f69d21e5f856 100644 (file)
@@ -17,7 +17,8 @@ namespace System.Data.SqlTypes
                #region Fields
 
                long value;
-               
+
+               private bool notNull;
                
                public static readonly SqlInt64 MaxValue = new SqlInt64 (9223372036854775807);
                public static readonly SqlInt64 MinValue = new SqlInt64 (-9223372036854775808);
@@ -32,6 +33,7 @@ namespace System.Data.SqlTypes
                public SqlInt64 (long value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                #endregion
@@ -39,7 +41,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public long Value { 
@@ -203,6 +205,9 @@ namespace System.Data.SqlTypes
 
                public override string ToString ()
                {
+                       if (this.IsNull)
+                               return "Null";
+
                        return value.ToString ();
                }
 
index 1767ee099dbe657c381e3267845889d3b4e6f482..34bb0084e66684558e745dadad49d3ed141e35d5 100644 (file)
@@ -17,8 +17,10 @@ namespace System.Data.SqlTypes
                #region Fields
 
                decimal value;
+               
+               private bool notNull;
 
-               public static readonly SqlMoney MaxValue = new SqlMoney (922337203685475.5807);
+               public static readonly SqlMoney MaxValue = new SqlMoney (922337203685477.5807);
                public static readonly SqlMoney MinValue = new SqlMoney (-922337203685477.5808);
                public static readonly SqlMoney Null;
                public static readonly SqlMoney Zero = new SqlMoney (0);
@@ -30,21 +32,25 @@ namespace System.Data.SqlTypes
                public SqlMoney (decimal value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                public SqlMoney (double value) 
                {
                        this.value = (decimal)value;
+                       notNull = true;
                }
 
                public SqlMoney (int value) 
                {
                        this.value = (decimal)value;
+                       notNull = true;
                }
 
                public SqlMoney (long value) 
                {
                        this.value = (decimal)value;
+                       notNull = true;
                }
 
                #endregion
@@ -53,7 +59,7 @@ namespace System.Data.SqlTypes
 
                [MonoTODO]
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public decimal Value { 
@@ -104,7 +110,6 @@ namespace System.Data.SqlTypes
                        return (x == y);
                }
 
-               [MonoTODO]
                public override int GetHashCode ()
                {
                        return (int)value;
@@ -140,10 +145,14 @@ namespace System.Data.SqlTypes
                        return (x != y);
                }
 
-               [MonoTODO]
                public static SqlMoney Parse (string s)
                {
-                       throw new NotImplementedException ();
+                       decimal d = Decimal.Parse (s);
+
+                       if (d > SqlMoney.MaxValue.Value || d < SqlMoney.MinValue.Value) 
+                               throw new OverflowException ("");
+                       
+                       return new SqlMoney (d);
                }
 
                public static SqlMoney Subtract (SqlMoney x, SqlMoney y)
@@ -332,10 +341,9 @@ namespace System.Data.SqlTypes
                                return new SqlMoney ((decimal)x.Value);
                }
 
-               [MonoTODO]
                public static explicit operator SqlMoney (SqlString x)
                {
-                       throw new NotImplementedException ();
+                       return SqlMoney.Parse (x.Value);
                }
 
                public static implicit operator SqlMoney (decimal x)
index 1578497a62ef19bad112dbb39a4cb2714045f8ea..a38a63271b94d6621ec2a6edc7c174ee20d9c1a5 100644 (file)
@@ -18,6 +18,8 @@ namespace System.Data.SqlTypes
 
                float value;
 
+               private bool notNull;
+
                public static readonly SqlSingle MaxValue = new SqlSingle (3.40282346638528859e38);
                public static readonly SqlSingle MinValue = new SqlSingle (-3.40282346638528859e38);
                public static readonly SqlSingle Null;
@@ -30,11 +32,13 @@ namespace System.Data.SqlTypes
                public SqlSingle (double value) 
                {
                        this.value = (float)value;
+                       notNull = true;
                }
 
                public SqlSingle (float value) 
                {
                        this.value = value;
+                       notNull = true;
                }
 
                #endregion
@@ -42,7 +46,7 @@ namespace System.Data.SqlTypes
                #region Properties
 
                public bool IsNull { 
-                       get { return (bool) (this == Null); }
+                       get { return !notNull; }
                }
 
                public float Value { 
@@ -95,7 +99,8 @@ namespace System.Data.SqlTypes
 
                public override int GetHashCode ()
                {
-                       return (int)value;
+                       long LongValue = (long) value;
+                       return (int)(LongValue ^ (LongValue >> 32));
                }
 
                public static SqlBoolean GreaterThan (SqlSingle x, SqlSingle y)
index 46f5c2f0d926b50f7ee021310500af27ff442194..8fa66dc91fbbb21079464d54a3f4e05c0c9a20c1 100644 (file)
@@ -26,6 +26,8 @@ namespace System.Data.SqlTypes
 
                string value;
 
+               private bool notNull;
+
                public static readonly int BinarySort;
                public static readonly int IgnoreCase;
                public static readonly int IgnoreKanaType;
@@ -41,6 +43,7 @@ namespace System.Data.SqlTypes
                public SqlString (string data) 
                {
                        this.value = data;
+                       notNull = true;
                }
 
                // init with a string data and locale id values.
@@ -48,6 +51,7 @@ namespace System.Data.SqlTypes
                public SqlString (string data, int lcid) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                // init with locale id, compare options, 
@@ -56,6 +60,7 @@ namespace System.Data.SqlTypes
                public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                // init with string data, locale id, and compare options
@@ -63,6 +68,7 @@ namespace System.Data.SqlTypes
                public SqlString (string data, int lcid, SqlCompareOptions compareOptions) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                // init with locale id, compare options, array of bytes data,
@@ -71,6 +77,7 @@ namespace System.Data.SqlTypes
                public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, bool fUnicode) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                // init with locale id, compare options, array of bytes data,
@@ -80,6 +87,7 @@ namespace System.Data.SqlTypes
                public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                // init with locale id, compare options, array of bytes data,
@@ -89,6 +97,7 @@ namespace System.Data.SqlTypes
                public SqlString (int lcid, SqlCompareOptions compareOptions, byte[] data, int index, int count, bool fUnicode) 
                {
                        throw new NotImplementedException ();
+                       notNull = true;
                }
 
                #endregion // Constructors
@@ -109,7 +118,7 @@ namespace System.Data.SqlTypes
                }
 
                public bool IsNull {
-                       get { return (bool) (this == SqlString.Null); }
+                       get { return !notNull; }
                }
 
                // geographics location and language (locale id)