From: <aye...@us...> - 2009-05-22 00:52:10
|
Revision: 4352 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4352&view=rev Author: ayenderahien Date: 2009-05-22 00:52:05 +0000 (Fri, 22 May 2009) Log Message: ----------- Committing the logging changes for sql batcher discussed on mailing list Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs Modified: trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-22 00:51:01 UTC (rev 4351) +++ trunk/nhibernate/src/NHibernate/AdoNet/SqlClientBatchingBatcher.cs 2009-05-22 00:52:05 UTC (rev 4352) @@ -36,24 +36,19 @@ { totalExpectedRowsAffected += expectation.ExpectedRowCount; IDbCommand batchUpdate = CurrentCommand; - if (log.IsDebugEnabled) + + string lineWithParameters = null; + if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) { - string lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); - if (Factory.Settings.SqlStatementLogger.IsDebugEnabled) - { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); - } - else - { - log.Debug("Adding to batch:" + lineWithParameters); - } + lineWithParameters = Factory.Settings.SqlStatementLogger.GetCommandLineWithParameters(batchUpdate); currentBatchCommandsLog.Append("Batch command: ").AppendLine(lineWithParameters); } - else + if (log.IsDebugEnabled) { - Factory.Settings.SqlStatementLogger.LogCommand("Adding to batch:", batchUpdate, FormatStyle.Basic); + log.Debug("Adding to batch:" + lineWithParameters); } - currentBatch.Append((System.Data.SqlClient.SqlCommand)batchUpdate); + currentBatch.Append((System.Data.SqlClient.SqlCommand) batchUpdate); + if (currentBatch.CountOfCommands >= batchSize) { DoExecuteBatch(batchUpdate); @@ -70,11 +65,7 @@ Factory.Settings.SqlStatementLogger.LogBatchCommand(currentBatchCommandsLog.ToString()); currentBatchCommandsLog = new StringBuilder(); } - else if (log.IsDebugEnabled) - { - log.Debug(currentBatchCommandsLog.ToString()); - currentBatchCommandsLog = new StringBuilder(); - } + int rowsAffected = currentBatch.ExecuteNonQuery(); Expectations.VerifyOutcomeBatched(totalExpectedRowsAffected, rowsAffected); Modified: trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-22 00:51:01 UTC (rev 4351) +++ trunk/nhibernate/src/NHibernate.Test/Ado/BatcherFixture.cs 2009-05-22 00:52:05 UTC (rev 4352) @@ -108,8 +108,8 @@ [Test] [Description(@"Activating the SQL and turning off the batcher's log the log stream: --should not contains any batch info --should contain SQL's log info +-should not contains adding to batch +-should contain batch command -the batcher should work.")] public void SqlLog() { @@ -120,7 +120,8 @@ sessions.Statistics.Clear(); FillDb(); string logs = sl.GetWholeLog(); - Assert.That(logs, Text.DoesNotContain("Batch command").IgnoreCase); + Assert.That(logs, Text.DoesNotContain("Addin to batch").IgnoreCase); + Assert.That(logs, Text.Contains("Batch command").IgnoreCase); Assert.That(logs, Text.Contains("INSERT").IgnoreCase); } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |