FirebirdSQL / NETProvider

Firebird ADO.NET Data Provider
https://firebirdsql.org/en/net-provider/
Other
161 stars 66 forks source link

Writing string via EF 6 contains unexpected bytes #1093

Closed stormcrow79 closed 1 year ago

stormcrow79 commented 1 year ago

Inserting or updating a string field using Entity Framework results in unexpected byte sequences when all of the following conditions are met:

Environment

create table tests (
  id int generated by default as identity primary key,
  name varchar(50) character set none,
  modified timestamp computed by (localtimestamp));

var connectionString = "DataSource=localhost;User=SYSDBA;Password=********;Database=employee;Character Set=WIN1252;";

context.Tests.Add(new Test() { Name = "O\u2019Grady" });

Expected outcome: name contains "O’Grady" with a curly apostrophe Actual outcome: name contains "O’Grady" (the UTF-8 bytes for U+2019)

This appears to be caused by the explicit use of UTF-8 in GenerateReturningSql.

if (param.FbDbType == FbDbType.VarChar || param.FbDbType == FbDbType.Char)
  startBlock.Append(" CHARACTER SET UTF8");

Removing this line seems to resolve this particular problem.

NOTE: This problem does NOT occur using Firebird 2.5.9.

stormcrow79 commented 1 year ago

FYI @wyldphyre

stormcrow79 commented 1 year ago

@cincuranet i've added our repro at https://github.com/stormcrow79/FirebirdSql.Data.FirebirdClient/tree/test-encodings

we're still trying to get the test suite running to investigate further.

cincuranet commented 1 year ago

EF6 provider is in maintenance/legacy mode. I do not plan releasing (except for security fixes, if any) more versions of this provider. If you feel like creating a good, quality, complete PR, I will consider merging it.

stormcrow79 commented 1 year ago

Hi @cincuranet, thanks for your feedback. We'll look into creating a PR for EF6.

Meantime we've just tested the EF Core provider and it does seem to behave the same way.

cincuranet commented 1 year ago

Create issue with test case for EF Core, please.