abhishekbhalani / mvc-mini-profiler

Automatically exported from code.google.com/p/mvc-mini-profiler
1 stars 0 forks source link

Bit SQL parameters not rendered correctly by SqlServerFormatter #115

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The SqlServerFormatter formats bit fields like so:

DECLARE @myflag bit = False,
        @myotherflag bit = True

It should convert the True/False to 1/0 like this:

DECLARE @myflag bit = 0,
        @myotherflag bit = 1

Original issue reported on code.google.com by keithhe...@gmail.com on 10 Oct 2011 at 11:18

GoogleCodeExporter commented 9 years ago
There's a similar issue with byte[] arrays - they should be:

DECLARE @mybytearray varbinary(max) = 0x01020304

Original comment by keithhe...@gmail.com on 13 Feb 2012 at 9:23

GoogleCodeExporter commented 9 years ago
I fixed the boolean one, not sure what to do with varbinary

Original comment by sam.saff...@gmail.com on 14 Feb 2012 at 4:53

GoogleCodeExporter commented 9 years ago
Not sure either - in some places (for instance password hash checking) that 
blob's quite small, but in others it's a zipped file several MB in size. It 
would be good for the former to be usable and the latter truncated in some way.

Maybe something like:

DECLARE @passwordHash varbinary(128) = 0x010203040506070809019,
        @fileToSave varbinary(max) = null /* 6798 bytes */

It could be worth doing something similar for strings too, as nvarchar(max) can 
also be very large.

Original comment by keithhe...@gmail.com on 14 Feb 2012 at 3:33

GoogleCodeExporter commented 9 years ago
a patch welcome here, struggling to get a 2.0 release out at the moment, happy 
with your suggestion above 

Original comment by sam.saff...@gmail.com on 15 Feb 2012 at 12:19

GoogleCodeExporter commented 9 years ago
SqlTimingParameter has a Value property that's a string - by the time 
SqlServerFormatter gets the parameter that already holds "System.Byte[]".

Converting the byte[] to the T-SQL string is fairly simple - it's:

  "0x" + BitConverter.ToString(bytes).Replace("-", "")

But that's for SQL Server, I'm not sure how to do it for Oracle or anything 
else. If it is consistent for all SQL variants then it could be done by 
changing GetFormattedParameterValue to store the 0x01020304 format in the first 
place.

I've done that as 
http://code.google.com/p/mvc-mini-profiler/issues/detail?id=135 and 
http://code.google.com/p/mvc-mini-profiler/issues/detail?id=136

However I think the parameter format may need to be per provider - ideally 
ISqlFormatter would handle the conversion to the string, which means that 
SqlTimingParameter.Value would be an object, and that would mean that either:

* [MiniProfilerSqlTimingParameters].[Value] column would have to be a 
varbinary(max).
* The conversion/truncation would have to happen before the timing parameter 
was saved, but to some intermediate format that any ISqlFormatter could handle 

Both of those have problems that I wouldn't want to introduce just before a 
major release.

Original comment by keithhe...@gmail.com on 15 Feb 2012 at 11:22

GoogleCodeExporter commented 9 years ago
well I pulled this in, I follow on the base translation bits, fairly involved 
change, we can wait a bit on it. 

If you feel like taking a stab at it, be my guest (also ideally can you submit 
patches via github, makes it much easier to consume) 

Original comment by sam.saff...@gmail.com on 20 Feb 2012 at 12:00

GoogleCodeExporter commented 9 years ago
Do you mind moving this to http://community.miniprofiler.com ... killing off 
google issues

Original comment by sam.saff...@gmail.com on 27 Apr 2012 at 11:41