Skip to content

Commit

Permalink
Fix order issue in parameter logic
Browse files Browse the repository at this point in the history
Parameters were previously being logged from the NpgsqlCommand, but
they should be logged from each NpgsqlStatement separately.

Fixes #2424
  • Loading branch information
roji committed Apr 10, 2019
1 parent f9bc1ca commit fb39cf5
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions src/Npgsql/NpgsqlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1274,15 +1274,17 @@ internal void FixupRowDescription(RowDescriptionMessage rowDescription, bool isF
void LogCommand()
{
var sb = new StringBuilder();
sb.Append("Executing statement(s):");
sb.AppendLine("Executing statement(s):");
foreach (var s in _statements)
sb.AppendLine().Append("\t").Append(s.SQL);

if (NpgsqlLogManager.IsParameterLoggingEnabled && Parameters.Any())
{
sb.AppendLine().AppendLine("Parameters:");
for (var i = 0; i < Parameters.Count; i++)
sb.Append("\t$").Append(i + 1).Append(": ").Append(Convert.ToString(Parameters[i].Value, CultureInfo.InvariantCulture));
sb.Append("\t").AppendLine(s.SQL);
var p = s.InputParameters;
if (NpgsqlLogManager.IsParameterLoggingEnabled && p.Count > 0)
{
sb.Append('\t').Append("Parameters:");
for (var i = 0; i < p.Count; i++)
sb.Append("\t$").Append(i + 1).Append(": ").Append(Convert.ToString(p[i].Value, CultureInfo.InvariantCulture));
}
}

Log.Debug(sb.ToString(), Connection.Connector.Id);
Expand Down

0 comments on commit fb39cf5

Please sign in to comment.