During debugging the tsqlt code, I have directly run the below statement without wrapping it as sp and my original table constraint got deleted and some data missing from the original table.
Exec tSQLt.FakeTable @TableName = N'DBO.Employee', @Identity=1; Exec tSQLt.FakeTable @TableName = N'DBO.Salary', @Identity=1;
How do I prevent running faketable statement in tsqlt is impacting the original table?
Ugh, been there... You can't prevent it, short of contributing to the project and putting a pull request in to add the functionality.
FakeTable creates a backup of your original table so you should be able to get the original table back. These backup table names start with
tSQLt.tempobject
and end in an identifier. You can delete the new "fake" table (which now has the name of your original table) and rename the tempobject table if/when you find it.Something I've done in the past is to query for a column that I know is in the table to find the name of the tSQLt table: