From 7ee559ce73bcd00dcaadfec61f2062312c4dbe12 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 1 Jun 2023 14:04:14 +0100 Subject: [PATCH 1/2] Added "COLLATE DATABASE_DEFAULT" in all the places that block moving to partial containment --- Source/Run_Methods.sql | 2 +- ...GetDataTypeOrComputedColumnDefinition.sfn.sql | 4 ++-- ...tSQLt.Private_GetForeignKeyDefinition.sfn.sql | 16 ++++++++-------- ...SQLt.Private_NoTransactionHandleTable.ssp.sql | 2 +- Source/tSQLt.Private_ScriptIndex.sfn.sql | 4 ++-- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/Source/Run_Methods.sql b/Source/Run_Methods.sql index 2395b8896..1576d812f 100644 --- a/Source/Run_Methods.sql +++ b/Source/Run_Methods.sql @@ -507,7 +507,7 @@ BEGIN SELECT TC.Name FROM tSQLt.TestClasses AS TC JOIN tSQLt.Private_NewTestClassList AS PNTCL - ON PNTCL.ClassName = TC.Name; + ON PNTCL.ClassName = TC.Name COLLATE DATABASE_DEFAULT; END; GO diff --git a/Source/tSQLt.Private_GetDataTypeOrComputedColumnDefinition.sfn.sql b/Source/tSQLt.Private_GetDataTypeOrComputedColumnDefinition.sfn.sql index 50a397bb1..4fc0a75bc 100644 --- a/Source/tSQLt.Private_GetDataTypeOrComputedColumnDefinition.sfn.sql +++ b/Source/tSQLt.Private_GetDataTypeOrComputedColumnDefinition.sfn.sql @@ -11,7 +11,7 @@ RETURN SELECT AS V(UserTypeId, MaxLength, Precision, Scale, CollationName, ObjectId, ColumnId, ReturnDetails) CROSS APPLY tSQLt.Private_GetFullTypeName(V.UserTypeId, V.MaxLength, V.Precision, V.Scale, V.CollationName) AS GFTN LEFT JOIN (SELECT 1 AS IsComputedColumn, - ' AS '+ cci.definition + CASE WHEN cci.is_persisted = 1 THEN ' PERSISTED' ELSE '' END AS ComputedColumnDefinition, + ' AS '+ cci.definition + CASE WHEN cci.is_persisted = 1 THEN ' PERSISTED' ELSE '' END COLLATE DATABASE_DEFAULT AS ComputedColumnDefinition, cci.object_id, cci.column_id FROM sys.computed_columns cci @@ -20,4 +20,4 @@ RETURN SELECT AND cc.column_id = V.ColumnId AND V.ReturnDetails = 1; ---Build- -GO +GO \ No newline at end of file diff --git a/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql b/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql index 925bf6fae..3388bbfc2 100644 --- a/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql +++ b/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql @@ -45,13 +45,13 @@ AS RETURN SELECT 'CONSTRAINT ' + name + ' FOREIGN KEY (' + parCols + ') REFERENCES ' + refName + '(' + refCols + ')'+ CASE WHEN @NoCascade = 1 THEN '' - ELSE delete_referential_action_cmd + ' ' + update_referential_action_cmd - END AS cmd, - CASE + ELSE delete_referential_action_cmd + ' ' + update_referential_action_cmd + END COLLATE DATABASE_DEFAULT AS cmd, + CASE WHEN RefTableIsFakedInd = 1 - THEN 'CREATE UNIQUE INDEX ' + tSQLt.Private::CreateUniqueObjectName() + ' ON ' + refName + '(' + refCols + ');' - ELSE '' - END CreIdxCmd + THEN 'CREATE UNIQUE INDEX ' + tSQLt.Private::CreateUniqueObjectName() + ' ON ' + refName + '(' + refCols + ');' + ELSE '' + END COLLATE DATABASE_DEFAULT AS CreIdxCmd FROM (SELECT QUOTENAME(SCHEMA_NAME(k.schema_id)) AS SchemaName, QUOTENAME(k.name) AS name, QUOTENAME(OBJECT_NAME(k.parent_object_id)) AS parName, @@ -79,7 +79,7 @@ RETURN SELECT 'CONSTRAINT ' + name + ' FOREIGN KEY (' + CROSS APPLY tSQLt.Private_GetForeignKeyParColumns(k.object_id) AS parCol CROSS APPLY tSQLt.Private_GetForeignKeyRefColumns(k.object_id) AS refCol LEFT JOIN sys.extended_properties e - ON e.name = 'tSQLt.Private_TestDouble_OrgObjectName' + ON e.name = 'tSQLt.FakeTable_OrgTableName' AND e.value = OBJECT_NAME(k.referenced_object_id) JOIN sys.tables refTab ON COALESCE(e.major_id,k.referenced_object_id) = refTab.object_id @@ -87,4 +87,4 @@ RETURN SELECT 'CONSTRAINT ' + name + ' FOREIGN KEY (' + AND k.object_id = OBJECT_ID(@SchemaName + '.' + @ForeignKeyName) )x; GO ----Build- +---Build- \ No newline at end of file diff --git a/Source/tSQLt.Private_NoTransactionHandleTable.ssp.sql b/Source/tSQLt.Private_NoTransactionHandleTable.ssp.sql index f7e580e1d..1aabbd9e1 100644 --- a/Source/tSQLt.Private_NoTransactionHandleTable.ssp.sql +++ b/Source/tSQLt.Private_NoTransactionHandleTable.ssp.sql @@ -29,7 +29,7 @@ BEGIN END; ELSE IF (@TableAction = 'Hide') BEGIN - IF (NOT EXISTS (SELECT 1 FROM tSQLt.Private_RenamedObjectLog ROL WHERE QUOTENAME(OBJECT_SCHEMA_NAME(ROL.ObjectId))+'.'+OriginalName = @FullTableName)) + IF (NOT EXISTS (SELECT 1 FROM tSQLt.Private_RenamedObjectLog ROL WHERE QUOTENAME(OBJECT_SCHEMA_NAME(ROL.ObjectId))+'.'+OriginalName COLLATE DATABASE_DEFAULT = @FullTableName)) BEGIN IF(OBJECT_ID(@FullTableName) IS NULL) BEGIN diff --git a/Source/tSQLt.Private_ScriptIndex.sfn.sql b/Source/tSQLt.Private_ScriptIndex.sfn.sql index 6de9f7c69..ceeb59538 100644 --- a/Source/tSQLt.Private_ScriptIndex.sfn.sql +++ b/Source/tSQLt.Private_ScriptIndex.sfn.sql @@ -42,7 +42,7 @@ RETURN THEN 'WITH(STATISTICS_ONLY = -1)' ELSE '' END + - ';' AS create_cmd + ';' COLLATE DATABASE_DEFAULT AS create_cmd FROM tSQLt.Private_SysIndexes AS I CROSS APPLY ( @@ -78,4 +78,4 @@ RETURN AND I.index_id = ISNULL(@index_id,I.index_id); GO ---Build- -GO +GO \ No newline at end of file From 6830a21184ac5a3f032dc2a2a918af12fba30738 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 1 Jun 2023 14:11:05 +0100 Subject: [PATCH 2/2] fixed accidental change --- Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql b/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql index 3388bbfc2..243b26de5 100644 --- a/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql +++ b/Source/tSQLt.Private_GetForeignKeyDefinition.sfn.sql @@ -79,7 +79,7 @@ RETURN SELECT 'CONSTRAINT ' + name + ' FOREIGN KEY (' + CROSS APPLY tSQLt.Private_GetForeignKeyParColumns(k.object_id) AS parCol CROSS APPLY tSQLt.Private_GetForeignKeyRefColumns(k.object_id) AS refCol LEFT JOIN sys.extended_properties e - ON e.name = 'tSQLt.FakeTable_OrgTableName' + ON e.name = 'tSQLt.Private_TestDouble_OrgObjectName' AND e.value = OBJECT_NAME(k.referenced_object_id) JOIN sys.tables refTab ON COALESCE(e.major_id,k.referenced_object_id) = refTab.object_id