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>2004-09-13 04:20:35 +0400
committerFrancisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com>2004-09-13 04:20:35 +0400
commitcf6bdb5c482f4108f3d2e090e1973b863804767d (patch)
tree1d539605afc5c5d672da49bb5c2035f837a55a56 /mcs/class/Npgsql/NpgsqlTypes
parent37de8e5a266e131200df6913e85f52fb30366c8d (diff)
2004-09-12 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
* NpgsqlTypes/NpgsqlTypesHelper: ConvertToBackend: Fixed code to handle null values properly when using extended query mode. Fix bug 955 in gborg. svn path=/trunk/mcs/; revision=33784
Diffstat (limited to 'mcs/class/Npgsql/NpgsqlTypes')
-rwxr-xr-xmcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs25
1 files changed, 16 insertions, 9 deletions
diff --git a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
index a709eee6c4b..d884a743739 100755
--- a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
+++ b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs
@@ -578,18 +578,25 @@ namespace NpgsqlTypes
/// <summary>
/// Perform a data conversion from a native object to
/// a backend representation.
- /// DBNull will always be converted to "NULL".
+ /// DBNull and null values are handled differently depending if a plain query is used
+ /// When
/// </summary>
/// <param name="NativeData">Native .NET object to be converted.</param>
- /// <param name="SuppressQuoting">Never add quotes (only applies to certain types).</param>
- public String ConvertToBackend(Object NativeData, Boolean SuppressQuoting)
- {
- if (NativeData == DBNull.Value) {
- return "NULL";
- } else if (_ConvertNativeToBackend != null) {
- return QuoteString(! SuppressQuoting, _ConvertNativeToBackend(this, NativeData));
+ /// <param name="ForExtendedQuery">Flag indicating if the conversion has to be done for
+ /// plain queries or extended queries</param>
+ public String ConvertToBackend(Object NativeData, Boolean ForExtendedQuery)
+ {
+ if ((NativeData == DBNull.Value) || (NativeData == null))
+ if (ForExtendedQuery)
+ return null; // Extended query expects null values be represented as null.
+ else
+ return "NULL"; // Plain queries exptects null values as string NULL.
+
+ else if (_ConvertNativeToBackend != null) {
+ return QuoteString(! ForExtendedQuery, _ConvertNativeToBackend(this, NativeData));
+
} else {
- return QuoteString(! SuppressQuoting, (String)Convert.ChangeType(NativeData, typeof(String), CultureInfo.InvariantCulture));
+ return QuoteString(! ForExtendedQuery, (String)Convert.ChangeType(NativeData, typeof(String), CultureInfo.InvariantCulture));
}
}