You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
Given the following tables as created by the script:
IF OBJECT_ID('Child') >0DROPTABLEChild
IF OBJECT_ID('Parent') >0DROPTABLEParentCREATETABLEParent
(
ParentId INT IDENTITY(1,1) NOT NULL,
Name NVARCHAR(128) NOT NULL
,CONSTRAINT [PK_Parent] PRIMARY KEY CLUSTERED (ParentId ASC)
) ON [PRIMARY];
CREATETABLEChild
(
ChildId INT IDENTITY(1,1) NOT NULL,
Name NVARCHAR(128) NOT NULL,
ParentId INTNOT NULL
,CONSTRAINT [PK_Child] PRIMARY KEY CLUSTERED (ChildId ASC)
) ON [PRIMARY];
ALTERTABLE Child ADD CONSTRAINT [FK_Child_Parent] FOREIGN KEY ([ParentId])
REFERENCES Parent (ParentId);
The command ssc pull incorrectly generates the foreign key association. This is the resulting script (catted for readability):
if not exists (select*fromsys.schemaswhere name ='dbo')
exec('create schema dbo')
go
if not exists (select*fromsys.objectswhere object_id = object_id('[dbo].[Child]') and type ='U')
create table [dbo].[Child]
(
[ChildId] intnot null identity(1, 1),
[Name] nvarchar(128) collate SQL_Latin1_General_CP1_CI_AS not null,
[ParentId] intnot null,
constraint [PK_Child] primary key ([ChildId] asc)
)
go
if not exists (select*fromsys.objectswhere object_id = object_id('[dbo].[Parent]') and type ='U')
create table [dbo].[Parent]
(
[ParentId] intnot null identity(1, 1),
[Name] nvarchar(128) collate SQL_Latin1_General_CP1_CI_AS not null,
constraint [PK_Parent] primary key ([ParentId] asc)
*alter table [dbo].[Parent] with check add constraint [FK_Child_Parent] foreign key([ParentId]) references [dbo].[Parent] ([ParentId]) alter table [dbo].[Parent] checkconstraint [FK_Child_Parent]*
)
go
Expected behavior
I would expect the foreign key to be created on the correct table (Child table) instead of the Parent table. I would also point out that the order of the alter is incorrectly included inside the create table and it does not compile correctly.
Steps to Reproduce
Execute the query included above.
ssc init
ssc pull
Other Information
Version 1.9.0 of ssc.
Tested on SQL Server 2014 Developer Edition.
Any other information i could give you simply ping me. I will try and take a look at the source once i get a chance.
The text was updated successfully, but these errors were encountered:
Type
What kind of issue is this?
Current Behavior
Given the following tables as created by the script:
The command ssc pull incorrectly generates the foreign key association. This is the resulting script (catted for readability):
Expected behavior
I would expect the foreign key to be created on the correct table (Child table) instead of the Parent table. I would also point out that the order of the alter is incorrectly included inside the create table and it does not compile correctly.
Steps to Reproduce
Other Information
The text was updated successfully, but these errors were encountered: