Permalink
Browse files

Refactored.

Removed static version of GetDbType() method and moved the body
to the overridden version. Since the dataScale and dataPrecision
params were no longer being used, there was no longer any reason
for the static version to exist. Also, it looks like the overridden
version was still being referenced and it did not contain the correct
mappings.
  • Loading branch information...
MikeZuber committed Feb 15, 2011
1 parent ac6f271 commit 751c9711520bda6b3e7732dd95ba5abd6e64ca0d
Showing with 11 additions and 62 deletions.
  1. +11 −62 SubSonic/DataProviders/OracleDataProvider.cs
@@ -391,8 +391,7 @@ public override TableSchema.Table GetTableSchema(string tableName, TableType tab
if(!String.IsNullOrEmpty(precision) && precision != "0")
column.NumberPrecision = int.Parse(precision);
- // column.DataType = GetDbType(rdr[OracleSchemaVariable.DATA_TYPE].ToString().ToLower());
- column.DataType = GetDbTypeOracle(rdr[OracleSchemaVariable.DATA_TYPE].ToString().ToLower(), column.NumberScale, column.NumberPrecision);
+ column.DataType = GetDbType(rdr[OracleSchemaVariable.DATA_TYPE].ToString().ToLower());
column.AutoIncrement = false;
int maxLength;
int.TryParse(rdr[OracleSchemaVariable.MAX_LENGTH].ToString(), out maxLength);
@@ -610,44 +609,27 @@ public override string GetForeignKeyTableName(string fkColumnName)
return result.ToString();
}
- /// <summary>
- /// Added to distinguish for ORACLE between float and integer
- /// To be accurate, we should test dataPrecision to determine what kind of int
- /// we deal with 32, 64, while not extactly true cause, for instance 77000 is 5 of dataprecision
- /// and doesn't fit an int16)
- /// 19/03/07 : due to mismatch casting between integer and decimal data type (i.e
- /// what is the real type returned by the OracleClient assembly which is decimal and
- /// returned type from this function, I decided to return always for number type,
- /// decimal). Works better.
+ /// <summary>
+ /// Maps Oracle-specific data types to generic System.Data.DbType types.
/// </summary>
- /// <param name="sqlType">Type of the SQL.</param>
- /// <param name="dataScale">The data scale.</param>
- /// <param name="dataPrecision">The data precision.</param>
- /// <returns></returns>
- public static DbType GetDbTypeOracle(string sqlType, int dataScale, int dataPrecision)
+ /// <param name="sqlType">Oracle data type</param>
+ /// <returns>DbType enum representing the specified Oracle data type.</returns>
+ public override DbType GetDbType(string sqlType)
{
switch(sqlType)
- {
- case "char":
+ {
+ case "char":
case "varchar":
- case "varchar2":
- case "clob":
+ case "varchar2":
+ case "clob":
return DbType.AnsiString;
case "nchar":
- case "nvarchar2":
+ case "nvarchar2":
case "nclob":
case "rowid": //Not sure about ROWID
return DbType.String;
case "number":
return DbType.Decimal;
- //if (dataScale > 0)
- //{
- // return DbType.Single;
- //}
- //else
- //{
- // return DbType.Int32;
- //}
case "float":
return DbType.Double;
case "raw":
@@ -662,39 +644,6 @@ public static DbType GetDbTypeOracle(string sqlType, int dataScale, int dataPrec
}
}
- /// <summary>
- /// Gets the type of the db.
- /// </summary>
- /// <param name="sqlType">Type of the SQL.</param>
- /// <returns></returns>
- public override DbType GetDbType(string sqlType)
- {
- switch(sqlType)
- {
- case "number":
- return DbType.Single;
- case "float":
- return DbType.Double;
- case "varchar2":
- case "varchar":
- case "char":
- case "nchar":
- case "nvarchar2":
- case "rowid":
- case "nclob":
- case "blob":
- return DbType.String;
- case "raw":
- case "long raw":
- return DbType.Binary;
- case "date":
- case "timestamp":
- return DbType.DateTime;
- default:
- return DbType.String;
- }
- }
-
/// <summary>
/// Gets the command.
/// </summary>

0 comments on commit 751c971

Please sign in to comment.