Fix for Oracle TIMESTAMP(n) and RAW

Nov 10, 2011 at 9:11 AM

I had some issues with Oracle like field length not recognized, RAW and TIMESTAMP(x) field not recognized and mapped as string.

Please note that RAW(16) will be handled as GUIDs (to remove this behavior just strip the part regarding RAW from line 56.

Here is how i fixed:

This in OracleMetadataReader.cs: line 84

                            var dataLength = oracleDataReader["data_length"]!=DBNull.Value ? Convert.ToInt32(oracleDataReader["data_length"]): null  as int?;
                            var dataPrecision =oracleDataReader["data_precision"] !=DBNull.Value? Convert.ToInt32(oracleDataReader["data_precision"]) :null as int?;
                            var dataScale = oracleDataReader["data_scale"]!=DBNull.Value ? Convert.ToInt32(oracleDataReader["data_scale"]) :null as int?;

This in in DataTypeMapper.cs: Line 7
            if (dataType == "DATE" ||dataType == "date" || dataType == "datetime" || dataType == "TIMESTAMP" ||
                dataType == "TIMESTAMP WITH TIME ZONE" || dataType == "TIMESTAMP WITH LOCAL TIME ZONE" ||
                dataType == "smalldatetime" || dataType.StartsWith("TIMESTAMP(") ) //Added TIMESTAMP(n) 
            {
                return typeof(DateTime);
            }
			if (dataType == "NUMBER" || dataType == "LONG" || dataType == "bigint" )
            {
                return typeof(long);
            }
            if (dataType == "smallint")
            {
                return typeof(Int16);
            }
            if (dataType == "tinyint")
            {
                return typeof(Byte);
            }
            if (dataType == "int" || dataType == "INTERVAL YEAR TO MONTH" || dataType == "BINARY_INTEGER" || dataType.Contains("int"))
            {
                return typeof(int);
            }
			if (dataType == "BINARY_DOUBLE" || dataType == "float" || dataType == "numeric")
            {
                return typeof(double);
            }
            if (dataType == "BINARY_FLOAT" || dataType == "FLOAT")
            {
                return typeof(float);
            }
            
            if (dataType == "INTERVAL DAY TO SECOND")
            {
                return typeof(TimeSpan);
            }
            if (dataType == "bit")
            {
                return typeof(Boolean);
            }
            if (dataType == "decimal" || dataType == "money" || dataType == "smallmoney" || dataType == "numeric")
            {
                return typeof(decimal);
            }
            if (dataType == "real")
            {
                return typeof(Single);
            }
            if (dataType == "uniqueidentifier" || (dataType=="RAW" && dataLength==16)) // Handle RAW(16) as GUIDs
            {
                return typeof(Guid);
            }
            if (dataType == "BLOB" || dataType == "BFILE *" || dataType == "LONG RAW" || dataType == "binary" ||
                dataType == "image" || dataType == "timestamp" || dataType == "varbinary"|| dataType == "RAW"//Handle remaining RAW types as BYTE[]
            {
                return typeof(byte[]);
            }