Always Encrypted: Incorrect drop & create deployment step order when computed column is dropped as a part column encryption
- Dominant language
- C#
- Stars
- 460
- Forks
- 29
- Avg merge
- 4d 9h
- Merged PRs (30d)
- 7
Description
- SqlPackage or DacFx Version: 162.1.172
- .NET Framework (Windows-only) or .NET Core:
- Environment (local platform and source/target platforms): SQL 2022 Windows
**Note:** This only happens for AE. Based on the initial investigation, DacFx creates correct deployment order for drop and create function.
**Steps to Reproduce: **
1. Create a table with few columns -- Table1
2. Create a table Table2 with foreign key reference to Table1 and computed column referencing below function Func1
3. Create a function Func1 which references or uses Table2
4. Encrypt any column in Table 1
**Expected:** Column in table1 is successfully encrypted.
**Actual:** Column encryption fails as it tries to drop the function Func1 before dropping the computed column in Table2.
DacFx generates the correct deployment step order but AE reorders the steps in function OrderStepsForAlwaysEncryptedWizardMigration as it need to run certain steps in single transaction.
In OrderStepsForAlwaysEncryptedWizardMigration, drop function is ordered before drop column referencing function.
Similarly, in OrderStepsForAlwaysEncryptedWizardMigration, step to add back the dropped column is before create function. This also cause the deployment to fail as it tries to add column reference the function which is not yet created.
**Did this occur in prior versions? If not - which version(s) did it work in?**
(DacFx/SqlPackage/SSMS/Azure Data Studio)
Contributor guide
Research direction
Start by reproducing the Always Encrypted scenario from the listed Table1, Table2, and Func1 steps, then inspect OrderStepsForAlwaysEncryptedWizardMigration, the entry point named in the issue. No source file or test is mentioned; done means column encryption succeeds with the function and computed-column drop and recreate steps in the required order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, sql
- Domain
- databases, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100