-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lots of ArgumentException in 2.0.7: "Metadata for field 'FieldName' of record '2' did not match the original record's metadata" #393
Comments
@cmeeren thanks for the report, can you share what the type provider instanciation looks like? The change in 2.0.7 is about table types, there was a tweak around constructing The unit tests of the library may not cover the specific type which fails, so I can add those to make sure there is no regression. |
Here's the TP instantiation: type Db =
SqlProgrammabilityProvider<"
Data Source=.;
Initial Catalog=MyDbName;
Integrated Security=True"> At runtime I use this connection string:
I invoke an sproc that uses TVP: use cmd = new Db.dbo.User_Save(connStr)
do!
cmd.AsyncExecute(
userId = dto.UserId,
...
sessions = (
dto.Sessions
|> Array.map (fun s ->
Db.dbo.``User-Defined Table Types``.SaveSession(
SessionId = s.SessionId,
...)
)
)
)
|> Async.Ignore<int> The table type is defined like this: CREATE TYPE [dbo].[SaveSession] AS TABLE
(
[SessionId] NVARCHAR(100) NOT NULL,
[IpAddress] NVARCHAR(45) NOT NULL,
[Source] TINYINT NULL,
[CreatedAt] DATETIMEOFFSET NOT NULL,
[LastActive] DATETIMEOFFSET NOT NULL,
[AbsoluteExpirationAfterSeconds] INT NOT NULL,
[InactiveExpirationAfterSeconds] INT NOT NULL,
[UserAgent] NVARCHAR(MAX) NULL
)
⚠ Note that I do not experience the problem if I connect to my local DB (the first connection string). |
We may deal with inconsistency among different versions of SQL Server, could you run the following query in both your local and production environment and bring back any difference you see between the two? select
c.name
, c.system_type_id
, c.user_type_id
, c.is_nullable
, c.max_length
, c.is_identity
, c.is_computed
, c.[precision]
, c.scale
from
sys.table_types as tt
inner join sys.columns as c on tt.type_table_object_id = c.object_id
order by
tt.user_type_id
, c.column_id |
mmmh, is it running on the application database or on the master database? AFAIU, it should return the definition of TVP. |
I ran it on the app databases. |
Ok, thanks, your best luck for now until I can reproduce it, would be to step through the provider itself through SqlClient.sln. I've tried to add a test with TVP containing You may try to debug the test from my branch: #394 running on same server where you face the issue. What version of SQL Server which causes the issue? |
Azure SQL. |
…leshoot-issue-393 add a test to try to address #393
@cmeeren I don't have access to any such version, if you can't debug it, if you could privately share an usable connection to me, I'll try to debug it over the coming days. |
I'll see what I can do. I came across a fix here for a similar issue in an unrelated repo. Could that help? |
During development of my own SQL wrapper generator (mentioned in #383 (comment) and soon to be released), I believe I have found the issue. I have not found it documented anywhere ( In other words, this is wrong (The SqlMetaData("datetime2", SqlDbType.DateTime2, 23uy, 3uy) // Column defined as datetime2(3)
SqlMetaData("datetimeoffset", SqlDbType.DateTimeOffset, 28uy, 1uy) // Column defined as datetimeoffset(1)
SqlMetaData("time", SqlDbType.Time, 10uy, 1uy) // Column defined as time(1) Whereas this works: SqlMetaData("datetime2", SqlDbType.DateTime2, 0uy, 3uy)
SqlMetaData("datetimeoffset", SqlDbType.DateTimeOffset, 0uy, 1uy)
SqlMetaData("time", SqlDbType.Time, 0uy, 1uy) I ran my (I daresay robust) suite of precision-loss-tests after making this change, and all tests still pass. Note:
|
…lazure tentative fix for #393 (sqlazure datetimeoffset & others in TVP)
Thanks. Unfortunately I am on holiday now, and when I'm back in January I will need to focus on migrating our services to Facil. (Updating all the APIs is a lot of churn, so I can't prioritize updating SqlClient first and then waiting for a likely fixed intermittent issue to manifest itself.) Thanks for fixing it, though. As mentioned previously, it looks correct. |
After updating to 2.0.7, I receive a lot of these:
Reverting to 2.0.6 fixes the problem.
The stack trace doesn't tell me anything useful, but perhaps you know something, given that it happens in 2.0.7 but not in 2.0.6.
The text was updated successfully, but these errors were encountered: