From 91dd88bd17e58aea14d12db30bcce22b876b31d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Krzysztof=20Strugin=CC=81ski?= Date: Fri, 15 Mar 2024 14:28:49 +0000 Subject: [PATCH] Fix SRD0024 issues --- latest/SqlCodeAnalysisRules.props | 1 - latest/tSQLt.Edge/Internal/tSQLt.Internal_ApplyIndex.sql | 2 +- latest/tSQLt.Edge/Internal/tSQLt.Internal_FakeTable.sql | 2 +- .../tSQLt.Edge/Private/tSQLt.Private_ApplyCheckConstraint.sql | 2 +- latest/tSQLt.Edge/Private/tSQLt.Private_ApplyForeignKey.sql | 4 ++-- latest/tSQLt.Edge/Private/tSQLt.Private_ApplyPrimaryKey.sql | 4 ++-- .../Private/tSQLt.Private_ApplyUniqueConstraint.sql | 2 +- latest/tSQLt.Edge/Private/tSQLt.Private_RenameObject.sql | 2 +- 8 files changed, 9 insertions(+), 10 deletions(-) diff --git a/latest/SqlCodeAnalysisRules.props b/latest/SqlCodeAnalysisRules.props index 2923d6b..1df5798 100644 --- a/latest/SqlCodeAnalysisRules.props +++ b/latest/SqlCodeAnalysisRules.props @@ -7,7 +7,6 @@ -SqlServer.Rules.SRD0013; $(CodeAnalysisRules) -SqlServer.Rules.SRD0015; $(CodeAnalysisRules) -SqlServer.Rules.SRD0017; $(CodeAnalysisRules) - -SqlServer.Rules.SRD0024; $(CodeAnalysisRules) -SqlServer.Rules.SRD0026; $(CodeAnalysisRules) -SqlServer.Rules.SRD0032; $(CodeAnalysisRules) -SqlServer.Rules.SRD0043; $(CodeAnalysisRules) diff --git a/latest/tSQLt.Edge/Internal/tSQLt.Internal_ApplyIndex.sql b/latest/tSQLt.Edge/Internal/tSQLt.Internal_ApplyIndex.sql index fc994df..540649c 100644 --- a/latest/tSQLt.Edge/Internal/tSQLt.Internal_ApplyIndex.sql +++ b/latest/tSQLt.Edge/Internal/tSQLt.Internal_ApplyIndex.sql @@ -47,7 +47,7 @@ BEGIN 'CREATE', @IndexUnique, @IndexType, 'INDEX', @IndexName, 'ON', @ObjectName, @IndexDefinition ) - EXEC (@CreateIndex); + EXEC sys.sp_executesql @CreateIndex; END ELSE BEGIN diff --git a/latest/tSQLt.Edge/Internal/tSQLt.Internal_FakeTable.sql b/latest/tSQLt.Edge/Internal/tSQLt.Internal_FakeTable.sql index 6147954..6055732 100644 --- a/latest/tSQLt.Edge/Internal/tSQLt.Internal_FakeTable.sql +++ b/latest/tSQLt.Edge/Internal/tSQLt.Internal_FakeTable.sql @@ -24,7 +24,7 @@ BEGIN DECLARE @NewTableName NVARCHAR(MAX); EXEC tSQLt.Private_RenameObject @TableName, @NewTableName OUTPUT; - EXEC (@CreateFakeTableCommand); + EXEC sys.sp_executesql @CreateFakeTableCommand; DECLARE @NewObjectId INT = OBJECT_ID(@TableName); INSERT INTO tSQLt.Private_FakeTables (ObjectId, ObjectName, FakeObjectId, FakeObjectName) diff --git a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyCheckConstraint.sql b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyCheckConstraint.sql index 5f0f2b5..1f38b49 100644 --- a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyCheckConstraint.sql +++ b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyCheckConstraint.sql @@ -21,6 +21,6 @@ BEGIN 'ALTER TABLE', @ObjectName, 'ADD CONSTRAINT', @ConstraintName, 'CHECK', @ConstraintDefinition ) - EXEC (@CreateConstraint); + EXEC sys.sp_executesql @CreateConstraint; END; GO \ No newline at end of file diff --git a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyForeignKey.sql b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyForeignKey.sql index 6816660..a1d391f 100644 --- a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyForeignKey.sql +++ b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyForeignKey.sql @@ -41,7 +41,7 @@ BEGIN 'ALTER TABLE', @ObjectName, 'ADD CONSTRAINT', @ConstraintName, 'FOREIGN KEY', @ConstraintDefinition ) - EXEC (@CreateUniqueIndex); - EXEC (@CreateForeignKey); + EXEC sys.sp_executesql @CreateUniqueIndex; + EXEC sys.sp_executesql @CreateForeignKey; END; GO \ No newline at end of file diff --git a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyPrimaryKey.sql b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyPrimaryKey.sql index f629275..2a57ede 100644 --- a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyPrimaryKey.sql +++ b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyPrimaryKey.sql @@ -139,7 +139,7 @@ BEGIN 'ALTER TABLE', @ObjectName, 'ADD CONSTRAINT', @ConstraintName, 'PRIMARY KEY', @ConstraintDefinition ) - EXEC (@AlterPrimaryColumns); - EXEC (@CreatePrimaryKey); + EXEC sys.sp_executesql @AlterPrimaryColumns; + EXEC sys.sp_executesql @CreatePrimaryKey; END; GO \ No newline at end of file diff --git a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyUniqueConstraint.sql b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyUniqueConstraint.sql index c2fdde8..ce3256a 100644 --- a/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyUniqueConstraint.sql +++ b/latest/tSQLt.Edge/Private/tSQLt.Private_ApplyUniqueConstraint.sql @@ -33,6 +33,6 @@ BEGIN 'ALTER TABLE', @ObjectName, 'ADD CONSTRAINT', @ConstraintName, 'UNIQUE', @ConstraintDefinition ) - EXEC (@CreateUniqueConstraint); + EXEC sys.sp_executesql @CreateUniqueConstraint; END; GO \ No newline at end of file diff --git a/latest/tSQLt.Edge/Private/tSQLt.Private_RenameObject.sql b/latest/tSQLt.Edge/Private/tSQLt.Private_RenameObject.sql index 089e2c7..fbd3af5 100644 --- a/latest/tSQLt.Edge/Private/tSQLt.Private_RenameObject.sql +++ b/latest/tSQLt.Edge/Private/tSQLt.Private_RenameObject.sql @@ -27,6 +27,6 @@ BEGIN QUOTENAME(@NewName) ); - EXEC (@Command); + EXEC sys.sp_executesql @Command; END; GO \ No newline at end of file