LinuxDoku / migratordotnet

Automatically exported from code.google.com/p/migratordotnet
0 stars 0 forks source link

Inserting values with string formatting entries like "{0}" failes because of tracing not handling this. #139

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Inserting values with string formatting with the Insert method failes when 
the inserted values contains tags like {0} the Trace method expects some 
formatting values.

What steps will reproduce the problem?
1. perform any insert with string values containing string formatting tags 
like {0}.
you should get exceptions like this. 

  [migrate] Index (zero based) must be greater than or equal to zero and 
less than the size of the argument list.
  [migrate]    at System.Text.StringBuilder.AppendFormat(IFormatProvider 
provider, String format, Object[] args)
  [migrate]    at System.String.Format(IFormatProvider provider, String 
format, Object[] args)
  [migrate]    at NAnt.Core.Task.Log(Level messageLevel, String message, 
Object[] args)
  [migrate]    at Migrator.NAnt.Loggers.TaskLogger.Trace(String format, 
Object[] args) in 
c:\tmp\Oss\MigratorDotNet\migratordotnet\src\Migrator.NAnt\Loggers\TaskLogg
er.cs:line 127
  [migrate]    at Migrator.Providers.TransformationProvider.ExecuteNonQuery
(String sql) in 
c:\tmp\Oss\MigratorDotNet\migratordotnet\src\Migrator.Providers\Transformat
ionProvider.cs:line 552

What is the expected output? What do you see instead?

I expect the value to be inserted and to see a message explaining that a 
value was inserted.

you could do something like logger.Trace("{0}", new[]{sql});
in the ExecuteNonQuery method instead. by doing this you would keep the 
SQL intact and wouldn't have to worry about values containing formatting.

What version of the product are you using? On what operating system? With 
what .NET implementation/version?
Product Version: 0.9.0.10081

What database and version are you seeing this issue on?
doesn't matter it failes before hitting the DB.

Please provide any additional information below.

Original issue reported on code.google.com by nez...@gmail.com on 8 Mar 2010 at 1:23