sqlx-sqlserver 0.0.3 currently decodes MssqlType::VarChar with std::str::from_utf8(bytes). That works for ASCII, but SQL Server VARCHAR bytes are encoded according to the column/database collation code page, not necessarily UTF-8.\n\nRepro shape observed while migrating SQLPage to sqlx-sqlserver:\n\nsql\nselect 'Tu gères '';'' et ''"'' ?' as msg;\n\n\nAgainst SQL Server this returns a VARCHAR value. Decoding it as String fails with an invalid UTF-8 sequence for the non-ASCII byte, so SQLPage sees the value as a decode error/null. The same text works when the query uses an NVARCHAR literal:\n\nsql\nselect N'Tu gères '';'' et ''"'' ?' as msg;\n\n\nThe relevant code appears to be in src/value.rs:\n\nrust\nif matches!(value.type_info.kind(), MssqlType::VarChar) {\n return Ok(std::str::from_utf8(bytes)?.to_owned());\n}\n\n\nExpected behavior: VARCHAR should be decoded according to the SQL Server codepage/collation metadata, or the crate should expose enough raw value information for callers to perform that fallback themselves.\n\nSQLPage can work around tests by using NVARCHAR literals where Unicode is required, but user queries returning existing VARCHAR columns with non-ASCII text will still hit this.
sqlx-sqlserver 0.0.3 currently decodes MssqlType::VarChar with std::str::from_utf8(bytes). That works for ASCII, but SQL Server VARCHAR bytes are encoded according to the column/database collation code page, not necessarily UTF-8.\n\nRepro shape observed while migrating SQLPage to sqlx-sqlserver:\n\n
sql\nselect 'Tu gères '';'' et ''"'' ?' as msg;\n\n\nAgainst SQL Server this returns a VARCHAR value. Decoding it as String fails with an invalid UTF-8 sequence for the non-ASCII byte, so SQLPage sees the value as a decode error/null. The same text works when the query uses an NVARCHAR literal:\n\nsql\nselect N'Tu gères '';'' et ''"'' ?' as msg;\n\n\nThe relevant code appears to be in src/value.rs:\n\nrust\nif matches!(value.type_info.kind(), MssqlType::VarChar) {\n return Ok(std::str::from_utf8(bytes)?.to_owned());\n}\n\n\nExpected behavior: VARCHAR should be decoded according to the SQL Server codepage/collation metadata, or the crate should expose enough raw value information for callers to perform that fallback themselves.\n\nSQLPage can work around tests by using NVARCHAR literals where Unicode is required, but user queries returning existing VARCHAR columns with non-ASCII text will still hit this.