umbraco / Umbraco.Forms.Issues

Public issue tracker for Umbraco Forms
29 stars 0 forks source link

SQLite Error 19: 'UNIQUE constraint failed: UFForms.Key'. #792

Closed Matthew-Wise closed 2 years ago

Matthew-Wise commented 2 years ago

When updating a form on a fresh version of v10 I get the following error:

SQLite Error 19: 'UNIQUE constraint failed: UFForms.Key'.

Reproduction

Create a form Name it Save it Save it

Specifics

Version 10 for Umbraco and Umbraco forms

Expected result

The forms is updated successfully

Actual result

SQLite Error 19: 'UNIQUE constraint failed: UFForms.Key'.

Exception Details Microsoft.Data.Sqlite.SqliteException, Microsoft.Data.Sqlite, Version=6.0.5.0, Culture=neutral, PublicKeyToken=adb9793829ddae60: SQLite Error 19: 'UNIQUE constraint failed: UFForms.Key'.


   at Microsoft.Data.Sqlite.SqliteDataReader.NextResult()
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.Data.Sqlite.SqliteCommand.ExecuteScalar()
   at Umbraco.Cms.Persistence.Sqlite.Services.SqlitePreferDeferredTransactionsConnection.CommandWrapper.ExecuteScalar()
   at StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteScalar() in C:\projects\dotnet\src\MiniProfiler.Shared\Data\ProfiledDbCommand.cs:line 343
   at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.<ExecuteScalar>b__32_0()
   at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func`1 func)
   at Umbraco.Cms.Infrastructure.Persistence.FaultHandling.FaultHandlingDbCommand.ExecuteScalar()
   at NPoco.Database.<>c__DisplayClass297_0.<ExecuteScalarHelper>b__0()
   at NPoco.Database.ExecuteScalarHelper(DbCommand cmd)
   at NPoco.DatabaseTypes.SQLiteDatabaseType.ExecuteInsert[T](Database db, DbCommand cmd, String primaryKeyName, Boolean useOutputClause, T poco, Object[] args)
   at NPoco.Database.InsertAsyncImp[T](PocoData pocoData, String tableName, String primaryKeyName, Boolean autoIncrement, T poco, Boolean sync)
   at NPoco.AsyncHelper.RunSync[T](Task`1 task)
   at NPoco.Database.Insert[T](String tableName, String primaryKeyName, Boolean autoIncrement, T poco)
   at NPoco.Database.Insert[T](T poco)
   at Umbraco.Forms.Core.Persistence.Repositories.Implement.FormRepository.PersistNewItem(IFormEntity entity)
   at Umbraco.Cms.Core.Cache.DefaultRepositoryCachePolicy`2.Create(TEntity entity, Action`1 persistNew)
   at Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement.EntityRepositoryBase`2.Save(TEntity entity)
   at Umbraco.Forms.Core.Services.BaseService`3.PerformSave(IScope scope, TEntity entity, TType item)
   at Umbraco.Forms.Core.Services.FormService.PerformSave(IScope scope, IFormEntity entity, Form form)
   at Umbraco.Forms.Core.Services.BaseService`3.Save(IScope scope, TEntity entity, TType item, EventMessages eventMessages, Dictionary`2 additionalData)
   at Umbraco.Forms.Core.Services.BaseService`3.Insert(TType item)
   at Umbraco.Forms.Web.Editors.FormController.SaveFormWithWorkflows(FormDesign formData)
   at Umbraco.Forms.Web.Editors.FormController.SaveForm(FormDesign formData)
   at lambda_method1227(Closure , Object , Object[] )
   at Microsoft.AspNetCore.Mvc.Infrastructure.ActionMethodExecutor.SyncObjectResultExecutor.Execute(IActionResultTypeMapper mapper, ObjectMethodExecutor executor, Object controller, Object[] arguments)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeActionMethodAsync()
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeNextActionFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Rethrow(ActionExecutedContextSealed context)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
   at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync()
--- End of stack trace from previous location ---
   at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|26_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted)```
Matthew-Wise commented 2 years ago

Just noticed deleting the form doesnt seem to work either, no visible error.

AndyButland commented 2 years ago

Thanks @Matthew-Wise - yes, both are caused by the same issue with deleting when using SQLite and using a Guid as the key. We'll get this fixed in a patch update as soon as possible.

AndyButland commented 2 years ago

10.0.1, including a fix for this issue, is released now to NuGet .