2005-09-30 Miguel de Icaza <miguel@novell.com>
[mono.git] / mcs / class / FirebirdSql.Data.Firebird / FirebirdSql.Data.Common / DbField.cs
index 18c31ec46adb5b650ed32a1bff0f49b637630f3c..bb5fbd665380e93efb1f1fb14c304f7e135a5669 100644 (file)
@@ -12,7 +12,7 @@
  *     express or implied.  See the License for the specific 
  *     language governing rights and limitations under the License.
  * 
- *  Copyright (c) 2002, 2004 Carlos Guzman Alvarez
+ *  Copyright (c) 2002, 2005 Carlos Guzman Alvarez
  *  All Rights Reserved.
  */
 
@@ -348,11 +348,13 @@ namespace FirebirdSql.Data.Common
                                                else
                                                {
                                                        string s = this.Charset.GetString(buffer, 0, buffer.Length);
+
                                                        if ((this.Length % this.Charset.BytesPerCharacter) == 0 &&
                                                                s.Length > this.CharCount)
                                                        {
                                                                s = s.Substring(0, this.CharCount);
                                                        }
+
                                                        this.Value = s;
                                                }
                                                break;
@@ -445,10 +447,13 @@ namespace FirebirdSql.Data.Common
                                {
                                        case DbDataType.Char:
                                        case DbDataType.VarChar:
-                                       case DbDataType.Guid:
                                                this.Value = String.Empty;
                                                break;
 
+                                       case DbDataType.Guid:
+                                               this.Value = Guid.Empty;
+                                               break;
+
                                        case DbDataType.SmallInt:
                                                this.Value = (short)0;
                                                break;
@@ -526,6 +531,8 @@ namespace FirebirdSql.Data.Common
                                        return Type.GetType("System.DateTime");
 
                                case DbDataType.Binary:
+                                       return typeof(byte[]);
+
                                case DbDataType.Array:
                                        return Type.GetType("System.Array");
 
@@ -556,56 +563,62 @@ namespace FirebirdSql.Data.Common
                                        return DbDataType.VarChar;
 
                                case IscCodes.SQL_SHORT:
-                                       if (this.numericScale < 0)
+                                       if (this.subType == 2)
                                        {
-                                               if (this.subType == 2)
-                                               {
-                                                       return DbDataType.Decimal;
-                                               }
-                                               else
-                                               {
-                                                       return DbDataType.Numeric;
-                                               }
+                                               return DbDataType.Decimal;
                                        }
-                                       else
+                    else if (subType == 1)
+                    {
+                        return DbDataType.Numeric;
+                    }
+                    else
                                        {
                                                return DbDataType.SmallInt;
                                        }
 
                                case IscCodes.SQL_LONG:
-                                       if (this.numericScale < 0)
+                                       if (this.subType == 2)
                                        {
-                                               if (this.subType == 2)
-                                               {
-                                                       return DbDataType.Decimal;
-                                               }
-                                               else
-                                               {
-                                                       return DbDataType.Numeric;
-                                               }
+                                               return DbDataType.Decimal;
                                        }
-                                       else
+                    else if (subType == 1)
+                    {
+                        return DbDataType.Numeric;
+                    }
+                    else
                                        {
                                                return DbDataType.Integer;
                                        }
 
+                               case IscCodes.SQL_QUAD:
+                               case IscCodes.SQL_INT64:
+                                       if (this.subType == 2)
+                                       {
+                                               return DbDataType.Decimal;
+                                       }
+                    else if (subType == 1)
+                    {
+                        return DbDataType.Numeric;
+                    }
+                    else
+                                       {
+                                               return DbDataType.BigInt;
+                                       }
+
                                case IscCodes.SQL_FLOAT:
                                        return DbDataType.Float;
 
                                case IscCodes.SQL_DOUBLE:
                                case IscCodes.SQL_D_FLOAT:
-                                       if (this.numericScale < 0)
+                                       if (this.subType == 2)
                                        {
-                                               if (this.subType == 2)
-                                               {
-                                                       return DbDataType.Decimal;
-                                               }
-                                               else
-                                               {
-                                                       return DbDataType.Numeric;
-                                               }
+                                               return DbDataType.Decimal;
                                        }
-                                       else
+                    else if (subType == 1)
+                    {
+                        return DbDataType.Numeric;
+                    }
+                    else
                                        {
                                                return DbDataType.Double;
                                        }
@@ -620,24 +633,6 @@ namespace FirebirdSql.Data.Common
                                                return DbDataType.Binary;
                                        }
 
-                               case IscCodes.SQL_QUAD:
-                               case IscCodes.SQL_INT64:
-                                       if (this.numericScale < 0)
-                                       {
-                                       if (this.subType == 2)
-                                               {
-                                                       return DbDataType.Decimal;
-                                               }
-                                               else
-                                               {
-                                                       return DbDataType.Numeric;
-                                               }
-                                       }
-                                       else
-                                       {
-                                               return DbDataType.BigInt;
-                                       }
-
                                case IscCodes.SQL_TIMESTAMP:
                                        return DbDataType.TimeStamp;