Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cascade delete behavior for FK between PKs in TPT #28532

Closed
smitpatel opened this issue Jul 28, 2022 · 1 comment · Fixed by #28965
Closed

Cascade delete behavior for FK between PKs in TPT #28532

smitpatel opened this issue Jul 28, 2022 · 1 comment · Fixed by #28965
Assignees
Labels
area-model-building breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Milestone

Comments

@smitpatel
Copy link
Member

Test Delete_where_using_hierarchy fails.
It is trying to delete entity which has dependent containing TPT. The failure indicates that cascade delete in TPT failed. Looking at database schema the FK doesn't contain cascade delete behavior.

USE [TPTInheritanceTest]
GO

/****** Object:  Table [dbo].[Birds]    Script Date: 7/28/2022 10:18:42 AM ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE TABLE [dbo].[Birds](
	[Species] [nvarchar](100) NOT NULL,
	[IsFlightless] [bit] NOT NULL,
	[EagleId] [nvarchar](100) NULL,
 CONSTRAINT [PK_Birds] PRIMARY KEY CLUSTERED 
(
	[Species] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, OPTIMIZE_FOR_SEQUENTIAL_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
GO

ALTER TABLE [dbo].[Birds]  WITH CHECK ADD  CONSTRAINT [FK_Birds_Animals_Species] FOREIGN KEY([Species])
REFERENCES [dbo].[Animals] ([Species])
GO

ALTER TABLE [dbo].[Birds] CHECK CONSTRAINT [FK_Birds_Animals_Species]
GO

ALTER TABLE [dbo].[Birds]  WITH CHECK ADD  CONSTRAINT [FK_Birds_Eagle_EagleId] FOREIGN KEY([EagleId])
REFERENCES [dbo].[Eagle] ([Species])
GO

ALTER TABLE [dbo].[Birds] CHECK CONSTRAINT [FK_Birds_Eagle_EagleId]
GO

@ajcvickers
Copy link
Member

Poaching

@ajcvickers ajcvickers assigned ajcvickers and unassigned AndriySvyryd Sep 2, 2022
ajcvickers added a commit that referenced this issue Sep 2, 2022
…linking across tables

E.g. for TPT.

Fixes #28532 (Cascade delete behavior for FK between PKs in TPT)

Note this is a breaking change--creating a cascade delete for the TPT relationship could cause a cycle with another existing cascade relationship. This is what happened with the GearsOfWar model.
@ajcvickers ajcvickers added closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. breaking-change labels Sep 2, 2022
ajcvickers added a commit that referenced this issue Sep 2, 2022
…linking across tables

E.g. for TPT.

Fixes #28532 (Cascade delete behavior for FK between PKs in TPT)

Note this is a breaking change--creating a cascade delete for the TPT relationship could cause a cycle with another existing cascade relationship. This is what happened with the GearsOfWar model.
@ajcvickers ajcvickers modified the milestones: 7.0.0, 7.0.0-rc2 Sep 9, 2022
@ajcvickers ajcvickers modified the milestones: 7.0.0-rc2, 7.0.0 Nov 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-model-building breaking-change closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. customer-reported type-bug
Projects
None yet
3 participants