Skip to content

V13.3.0 - Upgrade Error - SqlException: Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong. #16267

@justin-nevitech

Description

@justin-nevitech

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

13.3.0

Bug summary

Upgrading a site to V13.3.0 throws the following SQL exception on a database that was previously migrated from V7:

Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.###

Specifics

The error is caused by the following SQL statement for the V13.3.0 upgrade in the AlignContentVersionTable function within AlignUpgradedDatabase:

EXEC sp_rename N'DF_cmsContentVersion_VersionDate', N'DF_umbracoContentVersion_versionDate', N'OBJECT'

See here:

"EXEC sp_rename N'DF_cmsContentVersion_VersionDate', N'DF_umbracoContentVersion_versionDate', N'OBJECT'");

This is assuming the name of the constraint being renamed is DF_cmsContentVersion_VersionDate, but for some reason the name of the constraint in my database was DF__umbracoCo__Versi__6DCC4D03. Once I manually renamed the constraint to DF_cmsContentVersion_VersionDate the upgrade would continue and run successfully.

The database had recently been upgraded from V7 to V13.2.2 (via V8, V10, v11 and v12) but checking a copy of the V7 database the name of the constraint had been there since V7.

The full stack trace is:

Microsoft.Data.SqlClient.SqlException (0x80131904): Either the parameter @objname is ambiguous or the claimed @objtype (OBJECT) is wrong.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at Microsoft.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean isAsync, Int32 timeout, Boolean asyncWrite)
at Microsoft.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry, String methodName)
at Microsoft.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteNonQuery() in C:\\projects\\dotnet\\src\\MiniProfiler.Shared\\Data\\ProfiledDbCommand.cs:line 268
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.<ExecuteNonQuery>b__32_0()
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.<>c__DisplayClass38_0`1.<Execute>b__0()
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.Execute[T](Func`1 f)
at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.ExecuteNonQuery()
at NPoco.Database.<>c__DisplayClass296_0.<ExecuteNonQueryHelper>b__0()
at NPoco.Database.ExecutionHook[T](Func`1 action)
at NPoco.Database.ExecuteNonQueryHelper(DbCommand cmd)
at NPoco.Database.Execute(String sql, CommandType commandType, Object[] args)
at NPoco.Database.Execute(Sql Sql)
at Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_3_0.AlignUpgradedDatabase.AlignContentVersionTable(ColumnInfo[] columns)
at Umbraco.Cms.Infrastructure.Migrations.Upgrade.V_13_3_0.AlignUpgradedDatabase.Migrate()
at Umbraco.Cms.Infrastructure.Migrations.MigrationBase.Run()
at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunMigration(Type migrationType, MigrationContext context)
at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunScopedMigration(Type migrationType, MigrationPlan plan)
at Umbraco.Cms.Infrastructure.Migrations.MigrationPlanExecutor.RunMigrationPlan(MigrationPlan plan, String fromState)

I'm mainly included this here so anyone else that comes across this can find a solution.

Steps to reproduce

I've checked a few other V7 databases and found one other instance where the constraint was named differently, so I don't know at what point that constraint was created or by what. I don't have any other steps to reproduce other than what is already described above.

Expected result / actual result

The upgrade should not fail if it cannot find the constraint being renamed. As the constraint already exists (albeit with the wrong name), this should not cause any problems. If possible, the incorrect constraint name should be detected and renamed.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions