diff options
author | Francisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com> | 2004-05-22 20:44:57 +0400 |
---|---|---|
committer | Francisco Figueiredo Jr. <fxjr@mono-cvs.ximian.com> | 2004-05-22 20:44:57 +0400 |
commit | 4967a861905f8acdcc4b416cd4dd6ccbed902620 (patch) | |
tree | 49e7064d171fafa649cc63126e0cf45532c8ff05 /mcs/class/Npgsql/NpgsqlTypes | |
parent | 7d2226c1328efc24d2430e7ad324c31516e117b7 (diff) |
2004-05-22 Francisco Figueiredo Jr. <fxjrlists@yahoo.com.br>
Npgsql/NpgsqlCommand.cs,
Npgsql/NpgsqlConnection.cs,
Npgsql/NpgsqlDataReader.cs,
Npgsql/NpgsqlException.cs,
Npgsql/NpgsqlTransaction.cs,
Npgsql/Design/ConnectionStringEditor.cs,
Npgsql/Design/ConnectionStringEditorForm.cs,
Npgsql/Design/NpgsqlParameterConverter.cs,
Npgsql/Design/NpgsqlParametersEditor.cs,
NpgsqlTypes/NpgsqlTypesHelper.cs: Commit log by
Glen Parker (glenebob@nwlink.com): Bug #772 ("Using
Command and Prepare adds single quotes to strings twice")
is fixed :-) It was broken when running on the version 3
protocol (extended query support) on PostgreSQL 7.4.
Some of the files in Design were formatted with macintosh line
terminators. This was screwing up the xmldoc generator in csc,
so I reformatted to make it work.
I've added some essential xmldoc comments (<summary> tags). Much work
remains here, but I wanted to get a few in on common functions and
properties.
The .build file will now generate the Npgsql.xml file, next to the .dll
file. I removed the existing Npgsql.xml from CVS.
Thanks Glen Parker for this patch.
svn path=/trunk/mcs/; revision=27877
Diffstat (limited to 'mcs/class/Npgsql/NpgsqlTypes')
-rwxr-xr-x | mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs | 45 |
1 files changed, 38 insertions, 7 deletions
diff --git a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs index 9d8f407917b..521c0c422af 100755 --- a/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs +++ b/mcs/class/Npgsql/NpgsqlTypes/NpgsqlTypesHelper.cs @@ -186,8 +186,14 @@ namespace NpgsqlTypes } - public static String ConvertNpgsqlParameterToBackendStringValue(NpgsqlParameter parameter) + public static String ConvertNpgsqlParameterToBackendStringValue(NpgsqlParameter parameter, Boolean QuoteStrings) { + // HACK (?) + // glenebob@nwlink.com 05/20/2004 + // bool QuoteString is a bit of a hack. + // When using the version 3 extended query support, we do not need to do quoting of parameters. + // The backend handles that properly. + NpgsqlEventLog.LogMethodEnter(LogLevel.Debug, CLASSNAME, "ConvertNpgsqlParameterToBackendStringValue"); if ((parameter.Value == DBNull.Value) || (parameter.Value == null)) @@ -196,7 +202,12 @@ namespace NpgsqlTypes switch(parameter.DbType) { case DbType.Binary: - return "'" + ConvertByteArrayToBytea((Byte[])parameter.Value) + "'"; + if (QuoteStrings) { + return "'" + ConvertByteArrayToBytea((Byte[])parameter.Value) + "'"; + } else { + return ConvertByteArrayToBytea((Byte[])parameter.Value); + } + case DbType.Boolean: case DbType.Int64: case DbType.Int32: @@ -205,16 +216,28 @@ namespace NpgsqlTypes case DbType.Single: // To not have a value implicitly converted to float8, we add quotes. - return "'" + ((Single)parameter.Value).ToString(NumberFormatInfo.InvariantInfo) + "'"; + if (QuoteStrings) { + return "'" + ((Single)parameter.Value).ToString(NumberFormatInfo.InvariantInfo) + "'"; + } else { + 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") + "'"; + if (QuoteStrings) { + return "'" + ((DateTime)parameter.Value).ToString("yyyy-MM-dd") + "'"; + } else { + return ((DateTime)parameter.Value).ToString("yyyy-MM-dd"); + } case DbType.DateTime: - return "'" + ((DateTime)parameter.Value).ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + if (QuoteStrings) { + return "'" + ((DateTime)parameter.Value).ToString("yyyy-MM-dd HH:mm:ss.fff") + "'"; + } else { + return ((DateTime)parameter.Value).ToString("yyyy-MM-dd HH:mm:ss.fff"); + } case DbType.Decimal: return ((Decimal)parameter.Value).ToString(NumberFormatInfo.InvariantInfo); @@ -222,10 +245,18 @@ namespace NpgsqlTypes case DbType.String: case DbType.AnsiString: case DbType.StringFixedLength: - return "'" + parameter.Value.ToString().Replace("'", "\\'") + "'"; + if (QuoteStrings) { + return "'" + parameter.Value.ToString().Replace("'", "\\'") + "'"; + } else { + return parameter.Value.ToString(); + } case DbType.Time: - return "'" + ((DateTime)parameter.Value).ToString("HH:mm:ss.ffff") + "'"; + if (QuoteStrings) { + return "'" + ((DateTime)parameter.Value).ToString("HH:mm:ss.ffff") + "'"; + } else { + return ((DateTime)parameter.Value).ToString("HH:mm:ss.ffff"); + } default: // This should not happen! |