Using the v2.5 NuGet package _(FYI, I see no mention of v2.5 in this repo)._
I have a string[] property on a document class like so:
public string[] UrlHistory { get; set; }
I'm trying to duplicate it in a MartenRegistry subclass:
For<Feed>().DuplicateField(x => x.UrlHistory, "text[]");
The statements generated to setup the new column throw this exception (relevant sql at the bottom):
42804: column "url_history" is of type text[] but expression is of type jsonb'
Inner exceptions found, see $exception in variables window for more details.
Innermost exception Npgsql.PostgresException : 42804: column "url_history" is of type text[] but expression is of type jsonb
at Npgsql.NpgsqlConnector.<DoReadMessage>d__148.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlConnector.<ReadMessage>d__147.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Npgsql.NpgsqlConnector.<ReadMessage>d__147.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlConnector.<ReadExpecting>d__154`1.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlDataReader.<NextResult>d__32.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlDataReader.NextResult()
at Npgsql.NpgsqlCommand.<Execute>d__71.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at System.Runtime.CompilerServices.ValueTaskAwaiter`1.GetResult()
at Npgsql.NpgsqlCommand.<ExecuteNonQuery>d__84.MoveNext()
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Npgsql.NpgsqlCommand.ExecuteNonQuery()
at Marten.Storage.Tenant.generateOrUpdateFeature(Type featureType, IFeatureSchema feature)
Apparently failing statement:
alter table public.mt_doc_feed add column url_history text[] ;;update public.mt_doc_feed set url_history = CAST(data ->> 'UrlHistory' as jsonb);
@gcox Can you please use varchar[] instead of text[] i.e. For<Feed>().DuplicateField(x => x.UrlHistory, "varchar[]");, this will work without any issues.
This issue is a bug and we will attempt to fix the issue around usage of text[]
Since there's a workaround, I'm letting this slide out of 2.6.0 just for now
I'm not super thrilled about this, but a new test for the 2.9 release says that it's working fine. I think that https://github.com/JasperFx/marten/pull/1013 might have addressed this. I'm about to close this w/ a commit that has a test for this case.