microsoft / microsoft/DacFx

cannot change nvarchar to varchar with utf8 collation without disabling block on possible data loss

Open
#146 0 comments 0 reactions 0 assignees View on GitHub
area: deployment backlog bug
Dominant language
C#
Stars
460
Forks
29
Avg merge
4d 9h
Merged PRs (30d)
7

Description

- SqlPackage or DacFx Version: 17.0.62207.04100
- .NET Framework (Windows-only) or .NET Core: 4.8.04084
- Environment (local platform and source/target platforms): SQL Server 2019 CU10

**Steps to Reproduce:**

1. change an nvarchar column to varchar w/utf8 collation
2. deploy
3. error "Rows were detected. The schema update is terminating because data loss might occur."

according to the docs ([Converting to UTF-8](https://learn.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support?view=sql-server-ver16#converting)) there's no risk of truncation if the size is also increased sufficiently (to account for 2:3 expansion in the worst case). I tested nvarchar(150) to varchar(450) as well as varchar(max) with same results.

**Did this occur in prior versions? If not - which version(s) did it work in?**

haven't tried in previous versions, I think it just doesn't know about utf8 support?

Contributor guide

Open the contributing guide

Research direction

Reproduce the deployment with SQL Server 2019 using the reported nvarchar-to-varchar UTF-8 collation changes, including increased and max lengths. Trace the schema update's data-loss validation; done means a conversion that is safe at the target size no longer stops with the possible-data-loss error.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.