You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Microsoft.Data.Sqlite: SqliteParameter.Size = 0 sends an empty string or blob #39376
Setting SqliteParameter.Size to 0 truncates the bound value to nothing: a string is sent as "" and a byte[] as an empty blob. 0 is the parameter's default, so code that resets a reused parameter (parameter.Size = 0) silently stores empty values.
DbParameter.Size: "The default value is inferred from the parameter value." A new SqliteParameter reports Size 0, and when it is left unset the whole value is sent; assigning that same default explicitly should not change what is sent.
Why this is a bug
SqliteParameterBinder.ShouldTruncate treats any value other than -1 as a limit, so 0 truncates to zero characters or bytes. The truncation is silent: no exception, just an empty value stored. Positive sizes (Bind_with_restricted_size_works_on_*) and -1 (Bind_with_sentinel_size_works_on_*) are already covered and are unchanged by treating 0 as "no limit" too.
Reproduced on Microsoft.Data.Sqlite 6.0.36 through 10.0.13. I have a small change with tests.
Activity
Don't truncate SqliteParameter values when Size is 0 (dotnet#39377)