Decode SQL Server VARCHAR using column collation/codepage instead of UTF-8
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start in src/value.rs at the MssqlType::VarChar branch and trace what collation or type metadata is available through value.type_info. Reproduce the shown VARCHAR query with non-ASCII text, then verify that the value no longer becomes a decode error or that callers receive enough raw information for a fallback.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Rust
- Stars
- 4
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
ontola/atomic-server#1625 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
VirusTotal/yara-x#777 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
stratum-mining/stratum#2404 ·
-
bug ci good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100