Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>2003-07-15 04:27:34 +0400
committerFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>2003-07-15 04:27:34 +0400
commitb8b5be6a00f829c1de6e4195e787e9b18f1bb89f (patch)
treefbd44fc3dc523ca896e189a5857610e0c221085a /mcs/class/Npgsql/NpgsqlTypes
parent90652dc4a3a6995980870cd424eb08b104a9501c (diff)
2003-07-14: Francisco Figueiredo Jr. (fxjrlists@yahoo.com.br)
* Added support for float4 and float8 data types. svn path=/trunk/mcs/; revision=16243
Diffstat (limited to 'mcs/class/Npgsql/NpgsqlTypes')
-rwxr-xr-xmcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs34
1 files changed, 29 insertions, 5 deletions
diff --git a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
index 1f3fb2cbe4c..0175a5e8938 100755
--- a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
@@ -72,6 +72,10 @@ namespace NpgsqlTypes
{
case DbType.Boolean:
return "bool";
+ case DbType.Single:
+ return "float4";
+ case DbType.Double:
+ return "float8";
case DbType.Int64:
return "int8";
case DbType.Int32:
@@ -109,7 +113,13 @@ namespace NpgsqlTypes
case DbType.Int32:
case DbType.Int16:
return parameter.Value.ToString();
-
+ case DbType.Single:
+ // To not have a value implicitly converted to float8, we add quotes.
+ return "'" + ((Single)parameter.Value).ToString(NumberFormatInfo.InvariantInfo) + "'";
+
+ case DbType.Double:
+ return ((Double)parameter.Value).ToString(NumberFormatInfo.InvariantInfo);
+
case DbType.Date:
return "'" + ((DateTime)parameter.Value).ToString("yyyy-MM-dd") + "'";
@@ -154,6 +164,10 @@ namespace NpgsqlTypes
{
case DbType.Boolean:
return (data.ToLower() == "t" ? true : false);
+ case DbType.Single:
+ return Single.Parse(data, NumberFormatInfo.InvariantInfo);
+ case DbType.Double:
+ return Double.Parse(data, NumberFormatInfo.InvariantInfo);
case DbType.Int16:
return Int16.Parse(data);
case DbType.Int32:
@@ -226,6 +240,10 @@ namespace NpgsqlTypes
{
case DbType.Boolean:
return Type.GetType("System.Boolean");
+ case DbType.Single:
+ return Type.GetType("System.Single");
+ case DbType.Double:
+ return Type.GetType("System.Double");
case DbType.Int16:
return Type.GetType("System.Int16");
case DbType.Int32:
@@ -276,7 +294,7 @@ namespace NpgsqlTypes
// Bootstrap value as the datareader below will use ConvertStringToNpgsqlType above.
//oidToNameMapping.Add(26, "oid");
- NpgsqlCommand command = new NpgsqlCommand("select oid, typname from pg_type where typname in ('bool', 'date', 'int2', 'int4', 'int8', 'numeric', 'text', 'time', 'timestamp');", conn);
+ NpgsqlCommand command = new NpgsqlCommand("select oid, typname from pg_type where typname in ('bool', 'date', 'float4', 'float8', 'int2', 'int4', 'int8', 'numeric', 'text', 'time', 'timestamp');", conn);
NpgsqlDataReader dr = command.ExecuteReader();
@@ -297,9 +315,15 @@ namespace NpgsqlTypes
case "bool":
type = DbType.Boolean;
break;
- case "date":
- type = DbType.Date;
- break;
+ case "float4":
+ type = DbType.Single;
+ break;
+ case "float8":
+ type = DbType.Double;
+ break;
+ case "date":
+ type = DbType.Date;
+ break;
case "int2":
type = DbType.Int16;
break;