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
When a constraint needs quotes because it contains punctuations or spaces, tSQLt.ApplyConstraint fails because it passes parameters @SchemaName and @OriginalName without quotes to procedure tSQLt.Private_MarkObjectBeforeRename. Within this proc OBJECT_ID(@SchemaName + '.' + @OriginalName) evaluates to NULL.
T-SQL Code to reproduce:
create table dbo.MasterTbl(id int not null identity constraint [PK_Master] primary key clustered);
create table dbo.ChildTbl
(
id int not null identity constraint [PK_Child] primary key clustered
, masterId int not null constraint [FK.with.dots and spaces] foreign key references dbo.MasterTbl(id)
);
EXEC tSQLt.NewTestClass @ClassName = N'ConstraintTests';
CREATE PROCEDURE ConstraintTests.[test that fails to execute]
as
begin
exec tSQLt.FakeTable @TableName = N'dbo.MasterTbl';
exec tSQLt.FakeTable @TableName = N'dbo.ChildTbl';
exec tSQLt.ApplyConstraint @TableName = N'dbo.ChildTbl', @ConstraintName = N'FK.with.dots and spaces';
exec tSQLt.Fail @Message0 = N'Will never be executed, because tSQLt.ApplyConstraint fails';
end
GO
exec tSQLt.Run @TestName = N'ConstraintTests';
exec tSQLt.DropClass @ClassName = N'ConstraintTests';
drop table dbo.ChildTbl;
drop table dbo.MasterTbl;
The text was updated successfully, but these errors were encountered:
When a constraint needs quotes because it contains punctuations or spaces, tSQLt.ApplyConstraint fails because it passes parameters
@SchemaName
and@OriginalName
without quotes to proceduretSQLt.Private_MarkObjectBeforeRename
. Within this procOBJECT_ID(@SchemaName + '.' + @OriginalName)
evaluates to NULL.T-SQL Code to reproduce:
The text was updated successfully, but these errors were encountered: