Next i will create editor for my document type: RTE and Timing.
Fill some data and save
So this is what umbraco POSTs to the sever in 'varians' array
{
"id":4288,
"alias":"RTE Test",
"value":" *Actually there is 2048 chars*"
},
{
"id":4296,
"alias":"courseTiming",
"value":"If there is a string <=512 length, its saves OK. Otherwise it throws an exception below",
An error occured String or binary data would be truncated. The
statement has been terminated.
Exception Details System.Data.SqlClient.SqlException: String or binary
data would be truncated. The statement has been terminated.
Stacktrace at System.Data.SqlClient.SqlConnection.OnError(SqlException
exception, Boolean breakConnection, Action1 wrapCloseInAction) at
System.Data.SqlClient.SqlInternalConnection.OnError(SqlException
exception, Boolean breakConnection, Action1 wrapCloseInAction) at
System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject
stateObj, Boolean callerHasConnectionLock, Boolean asyncClose) at
System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior,
SqlCommand cmdHandler, SqlDataReader dataStream,
BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject
stateObj, Boolean& dataReady) at
System.Data.SqlClient.SqlDataReader.TryConsumeMetaData() at
System.Data.SqlClient.SqlDataReader.getMetaData() at
System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds,
RunBehavior runBehavior, String resetOptionsString, Boolean
isInternal, Boolean forDescribeParameterEncryption, Boolean
shouldCacheForAlwaysEncrypted) at
System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean
async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry,
SqlDataReader ds, Boolean describeParameterEncryptionRequest) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method, TaskCompletionSource1 completion, Int32 timeout, Task& task,
Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) at
System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior
cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String
method) at System.Data.SqlClient.SqlCommand.ExecuteScalar() at
StackExchange.Profiling.Data.ProfiledDbCommand.ExecuteScalar() in
C:\projects\dotnet\src\MiniProfiler.Shared\Data\ProfiledDbCommand.cs:line
334 at
Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.<ExecuteScalar>b__32_0()
in
d:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line
214 at
Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.<>c__DisplayClass33_01.0()
in
d:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line
222 at
Umbraco.Core.Persistence.FaultHandling.RetryPolicy.ExecuteAction[TResult](Func1
func) in
d:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryPolicy.cs:line
172 at
Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.Execute[T](Func1
f) in
d:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line
219 at
Umbraco.Core.Persistence.FaultHandling.FaultHandlingDbCommand.ExecuteScalar()
in
d:\a\1\s\src\Umbraco.Core\Persistence\FaultHandling\RetryDbConnection.cs:line
214 at NPoco.Database.ExecuteScalarHelper(DbCommand cmd) at
NPoco.DatabaseTypes.SqlServerDatabaseType.ExecuteInsert[T](Database
db, DbCommand cmd, String primaryKeyName, Boolean useOutputClause, T
poco, Object[] args) at NPoco.Database.InsertImp[T](PocoData
pocoData, String tableName, String primaryKeyName, Boolean
autoIncrement, T poco) at NPoco.Database.Insert[T](String
tableName, String primaryKeyName, Boolean autoIncrement, T poco) at
NPoco.Database.Insert[T](T poco) at
Umbraco.Core.Persistence.Repositories.Implement.DocumentRepository.PersistUpdatedItem(IContent
entity) in
d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\DocumentRepository.cs:line
527 at
Umbraco.Core.Cache.DefaultRepositoryCachePolicy2.Update(TEntity
entity, Action1 persistUpdated) in
d:\a\1\s\src\Umbraco.Core\Cache\DefaultRepositoryCachePolicy.cs:line
128 at
Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase2.Save(TEntity
entity) in
d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\RepositoryBaseOfTIdTEntity.cs:line
140 at Umbraco.Core.Services.Implement.ContentService.Save(IContent
content, Int32 userId, Boolean raiseEvents) in
d:\a\1\s\src\Umbraco.Core\Services\Implement\ContentService.cs:line
793 at
Umbraco.Web.Editors.ContentController.<>c__DisplayClass29_0.<PostSave>b__0(IContent
content) in d:\a\1\s\src\Umbraco.Web\Editors\ContentController.cs:line
601 at
Umbraco.Web.Editors.ContentController.SaveAndNotify(ContentItemSave
contentItem, Func2 saveMethod, Int32 variantCount, Dictionary2
notifications, SimpleNotificationModel globalNotifications, String
invariantSavedLocalizationKey, String variantSavedLocalizationKey,
String cultureForInvariantErrors, Boolean& wasCancelled) in
d:\a\1\s\src\Umbraco.Web\Editors\ContentController.cs:line 893 at
Umbraco.Web.Editors.ContentController.PostSaveInternal(ContentItemSave
contentItem, Func2 saveMethod, Func`2 mapToDisplay) in
d:\a\1\s\src\Umbraco.Web\Editors\ContentController.cs:line 688 at
Umbraco.Web.Editors.ContentController.PostSave(ContentItemSave
contentItem) in
d:\a\1\s\src\Umbraco.Web\Editors\ContentController.cs:line 599 at
lambdamethod(Closure , Object , Object[] )
RTE values itself saves ok whatever length you choose. I've added it here just to show the difference.
meanwhile my cusom editor's value cannot be more then 512 chars
I think this is an old, but known problem with the JSON valueType. It'll be defined as "nVarchar(500)" or maybe nVarchar(512)? One solution is to change your type from JSON to TEXT since text will give you a Ntext sql column type.
String or binary data will be truncated on content save
Preconditions: I've created my own property editor, filled some data and would like it to be saved
Next i will create editor for my document type: RTE and Timing. Fill some data and save
So this is what umbraco POSTs to the sever in 'varians' array
RTE values itself saves ok whatever length you choose. I've added it here just to show the difference. meanwhile my cusom editor's value cannot be more then 512 chars
Is there any suggestion how to avoid this bug?
I think this is an old, but known problem with the JSON valueType. It'll be defined as "nVarchar(500)" or maybe nVarchar(512)? One solution is to change your type from JSON to TEXT since text will give you a Ntext sql column type.
See here for more: https://our.umbraco.com/forum/core/general/40332-Unable-to-publish-String-or-binary-data-would-be-truncated
-Tor
Just removed property from document type and added again. And it worked. Magic
is working on a reply...