diff --git a/src/CoreTests/StoreOptionsTests.cs b/src/CoreTests/StoreOptionsTests.cs index ac7193f47b..d75551d0a0 100644 --- a/src/CoreTests/StoreOptionsTests.cs +++ b/src/CoreTests/StoreOptionsTests.cs @@ -2,6 +2,7 @@ using System.Linq; using System.Text.Json; using JasperFx.CodeGeneration; +using JasperFx.Core.Descriptions; using Marten; using Marten.Services; using Marten.Storage; @@ -441,6 +442,13 @@ public void maybe_correct_tenant_id(TenantIdStyle style, string tenantId, string options.MaybeCorrectTenantId(tenantId).ShouldBe(corrected); } + [Fact] + public void can_generate_options_description() + { + // just a smoke test + var description = new OptionsDescription(new StoreOptions()); + } + private class DummyNpgsqlDataSourceFactory: INpgsqlDataSourceFactory { diff --git a/src/Marten/Marten.csproj b/src/Marten/Marten.csproj index 40c936c3bb..215b2496c2 100644 --- a/src/Marten/Marten.csproj +++ b/src/Marten/Marten.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/Marten/StoreOptions.cs b/src/Marten/StoreOptions.cs index 0dd7fad2ef..3f62cba050 100644 --- a/src/Marten/StoreOptions.cs +++ b/src/Marten/StoreOptions.cs @@ -8,6 +8,7 @@ using System.Text.Json; using JasperFx.CodeGeneration; using JasperFx.Core; +using JasperFx.Core.Descriptions; using JasperFx.Core.Reflection; using Marten.Events; using Marten.Events.Daemon; @@ -261,6 +262,7 @@ public TypeLoadMode GeneratedCodeMode /// /// Access to adding custom schema features to this Marten-enabled Postgresql database /// + [IgnoreDescription] public StorageFeatures Storage => _storage; internal Action? CreateDatabases @@ -274,6 +276,7 @@ internal Action? CreateDatabases /// /// Advanced configuration options for this DocumentStore /// + [ChildDescription] public AdvancedOptions Advanced => _advanced; internal EventGraph EventGraph => _eventGraph; @@ -286,11 +289,13 @@ internal Action? CreateDatabases /// /// Extension point to add custom Linq query parsers /// + [IgnoreDescription] public LinqParsing Linq => _linq; /// /// Apply conventional policies to how documents are mapped /// + [IgnoreDescription] public PoliciesExpression Policies => new(this); @@ -394,6 +399,7 @@ void IReadOnlyStoreOptions.AssertDocumentTypeIsSoftDeleted(Type documentType) /// /// Get or set the tenancy model for this DocumentStore /// + [IgnoreDescription] public ITenancy Tenancy { get => (_tenancy ?? throw new InvalidOperationException( diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/ClassProvider1873568694.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ClassProvider1873568694.cs new file mode 100644 index 0000000000..6cf6dd7aed --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ClassProvider1873568694.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertClassOperation1873568694 + public class UpsertClassOperation1873568694 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Class _document; + private readonly ValueTypeTests.ClassId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertClassOperation1873568694(ValueTypeTests.Class document, ValueTypeTests.ClassId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Class document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_upsert_class("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertClassOperation1873568694 + + + // START: InsertClassOperation1873568694 + public class InsertClassOperation1873568694 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Class _document; + private readonly ValueTypeTests.ClassId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertClassOperation1873568694(ValueTypeTests.Class document, ValueTypeTests.ClassId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Class document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_insert_class("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertClassOperation1873568694 + + + // START: UpdateClassOperation1873568694 + public class UpdateClassOperation1873568694 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Class _document; + private readonly ValueTypeTests.ClassId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateClassOperation1873568694(ValueTypeTests.Class document, ValueTypeTests.ClassId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Class document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_update_class("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateClassOperation1873568694 + + + // START: QueryOnlyClassSelector1873568694 + public class QueryOnlyClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyClassSelector1873568694 + + + // START: LightweightClassSelector1873568694 + public class LightweightClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.ClassId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.ClassId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightClassSelector1873568694 + + + // START: IdentityMapClassSelector1873568694 + public class IdentityMapClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.ClassId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.ClassId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapClassSelector1873568694 + + + // START: DirtyTrackingClassSelector1873568694 + public class DirtyTrackingClassSelector1873568694 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingClassSelector1873568694(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Class Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.ClassId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.ClassId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Class document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingClassSelector1873568694 + + + // START: QueryOnlyClassDocumentStorage1873568694 + public class QueryOnlyClassDocumentStorage1873568694 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyClassDocumentStorage1873568694 + + + // START: LightweightClassDocumentStorage1873568694 + public class LightweightClassDocumentStorage1873568694 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightClassDocumentStorage1873568694 + + + // START: IdentityMapClassDocumentStorage1873568694 + public class IdentityMapClassDocumentStorage1873568694 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapClassDocumentStorage1873568694 + + + // START: DirtyTrackingClassDocumentStorage1873568694 + public class DirtyTrackingClassDocumentStorage1873568694 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingClassDocumentStorage1873568694(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.ClassId AssignIdentity(ValueTypeTests.Class document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.ClassId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertClassOperation1873568694 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Class document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.ClassId Identity(ValueTypeTests.Class document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingClassSelector1873568694(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.ClassId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.ClassId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingClassDocumentStorage1873568694 + + + // START: ClassBulkLoader1873568694 + public class ClassBulkLoader1873568694 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public ClassBulkLoader1873568694(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed24.mt_doc_class(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_class_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed24.mt_doc_class (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_class_temp.\"id\", mt_doc_class_temp.\"data\", mt_doc_class_temp.\"mt_version\", mt_doc_class_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_class_temp left join strong_typed24.mt_doc_class on mt_doc_class_temp.id = strong_typed24.mt_doc_class.id where strong_typed24.mt_doc_class.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed24.mt_doc_class target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_class_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_class_temp (like strong_typed24.mt_doc_class including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Class document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Class document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: ClassBulkLoader1873568694 + + + // START: ClassProvider1873568694 + public class ClassProvider1873568694 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public ClassProvider1873568694(Marten.Schema.DocumentMapping mapping) : base(new ClassBulkLoader1873568694(new QueryOnlyClassDocumentStorage1873568694(mapping)), new QueryOnlyClassDocumentStorage1873568694(mapping), new LightweightClassDocumentStorage1873568694(mapping), new IdentityMapClassDocumentStorage1873568694(mapping), new DirtyTrackingClassDocumentStorage1873568694(mapping)) + { + _mapping = mapping; + } + + + } + + // END: ClassProvider1873568694 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/GradeProvider907442297.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/GradeProvider907442297.cs new file mode 100644 index 0000000000..9dbc8ec683 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/GradeProvider907442297.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertGradeOperation907442297 + public class UpsertGradeOperation907442297 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Grade _document; + private readonly ValueTypeTests.GradeId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertGradeOperation907442297(ValueTypeTests.Grade document, ValueTypeTests.GradeId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Grade document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_upsert_grade("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertGradeOperation907442297 + + + // START: InsertGradeOperation907442297 + public class InsertGradeOperation907442297 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Grade _document; + private readonly ValueTypeTests.GradeId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertGradeOperation907442297(ValueTypeTests.Grade document, ValueTypeTests.GradeId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Grade document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_insert_grade("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertGradeOperation907442297 + + + // START: UpdateGradeOperation907442297 + public class UpdateGradeOperation907442297 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Grade _document; + private readonly ValueTypeTests.GradeId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateGradeOperation907442297(ValueTypeTests.Grade document, ValueTypeTests.GradeId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Grade document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_update_grade("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateGradeOperation907442297 + + + // START: QueryOnlyGradeSelector907442297 + public class QueryOnlyGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyGradeSelector907442297 + + + // START: LightweightGradeSelector907442297 + public class LightweightGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.GradeId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.GradeId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightGradeSelector907442297 + + + // START: IdentityMapGradeSelector907442297 + public class IdentityMapGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.GradeId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.GradeId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapGradeSelector907442297 + + + // START: DirtyTrackingGradeSelector907442297 + public class DirtyTrackingGradeSelector907442297 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingGradeSelector907442297(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Grade Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.GradeId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.GradeId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Grade document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingGradeSelector907442297 + + + // START: QueryOnlyGradeDocumentStorage907442297 + public class QueryOnlyGradeDocumentStorage907442297 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyGradeDocumentStorage907442297 + + + // START: LightweightGradeDocumentStorage907442297 + public class LightweightGradeDocumentStorage907442297 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightGradeDocumentStorage907442297 + + + // START: IdentityMapGradeDocumentStorage907442297 + public class IdentityMapGradeDocumentStorage907442297 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapGradeDocumentStorage907442297 + + + // START: DirtyTrackingGradeDocumentStorage907442297 + public class DirtyTrackingGradeDocumentStorage907442297 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingGradeDocumentStorage907442297(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.GradeId AssignIdentity(ValueTypeTests.Grade document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.GradeId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertGradeOperation907442297 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Grade document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.GradeId Identity(ValueTypeTests.Grade document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingGradeSelector907442297(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.GradeId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.GradeId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingGradeDocumentStorage907442297 + + + // START: GradeBulkLoader907442297 + public class GradeBulkLoader907442297 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public GradeBulkLoader907442297(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed24.mt_doc_grade(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_grade_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed24.mt_doc_grade (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_grade_temp.\"id\", mt_doc_grade_temp.\"data\", mt_doc_grade_temp.\"mt_version\", mt_doc_grade_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_grade_temp left join strong_typed24.mt_doc_grade on mt_doc_grade_temp.id = strong_typed24.mt_doc_grade.id where strong_typed24.mt_doc_grade.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed24.mt_doc_grade target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_grade_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_grade_temp (like strong_typed24.mt_doc_grade including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Grade document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Grade document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: GradeBulkLoader907442297 + + + // START: GradeProvider907442297 + public class GradeProvider907442297 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public GradeProvider907442297(Marten.Schema.DocumentMapping mapping) : base(new GradeBulkLoader907442297(new QueryOnlyGradeDocumentStorage907442297(mapping)), new QueryOnlyGradeDocumentStorage907442297(mapping), new LightweightGradeDocumentStorage907442297(mapping), new IdentityMapGradeDocumentStorage907442297(mapping), new DirtyTrackingGradeDocumentStorage907442297(mapping)) + { + _mapping = mapping; + } + + + } + + // END: GradeProvider907442297 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice2Provider479877131.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice2Provider479877131.cs new file mode 100644 index 0000000000..3ed6444a25 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice2Provider479877131.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoice2Operation479877131 + public class UpsertInvoice2Operation479877131 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice2 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoice2Operation479877131(ValueTypeTests.StrongTypedId.Invoice2 document, ValueTypeTests.StrongTypedId.Invoice2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed1.mt_upsert_invoice2("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertInvoice2Operation479877131 + + + // START: InsertInvoice2Operation479877131 + public class InsertInvoice2Operation479877131 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice2 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoice2Operation479877131(ValueTypeTests.StrongTypedId.Invoice2 document, ValueTypeTests.StrongTypedId.Invoice2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed1.mt_insert_invoice2("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertInvoice2Operation479877131 + + + // START: UpdateInvoice2Operation479877131 + public class UpdateInvoice2Operation479877131 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice2 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoice2Operation479877131(ValueTypeTests.StrongTypedId.Invoice2 document, ValueTypeTests.StrongTypedId.Invoice2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed1.mt_update_invoice2("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateInvoice2Operation479877131 + + + // START: QueryOnlyInvoice2Selector479877131 + public class QueryOnlyInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoice2Selector479877131 + + + // START: LightweightInvoice2Selector479877131 + public class LightweightInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoice2Selector479877131 + + + // START: IdentityMapInvoice2Selector479877131 + public class IdentityMapInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoice2Selector479877131 + + + // START: DirtyTrackingInvoice2Selector479877131 + public class DirtyTrackingInvoice2Selector479877131 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoice2Selector479877131(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoice2Selector479877131 + + + // START: QueryOnlyInvoice2DocumentStorage479877131 + public class QueryOnlyInvoice2DocumentStorage479877131 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyInvoice2DocumentStorage479877131 + + + // START: LightweightInvoice2DocumentStorage479877131 + public class LightweightInvoice2DocumentStorage479877131 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightInvoice2DocumentStorage479877131 + + + // START: IdentityMapInvoice2DocumentStorage479877131 + public class IdentityMapInvoice2DocumentStorage479877131 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapInvoice2DocumentStorage479877131 + + + // START: DirtyTrackingInvoice2DocumentStorage479877131 + public class DirtyTrackingInvoice2DocumentStorage479877131 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoice2DocumentStorage479877131(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice2Operation479877131 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoice2Selector479877131(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingInvoice2DocumentStorage479877131 + + + // START: Invoice2BulkLoader479877131 + public class Invoice2BulkLoader479877131 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Invoice2BulkLoader479877131(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed1.mt_doc_invoice2(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice2_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed1.mt_doc_invoice2 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice2_temp.\"id\", mt_doc_invoice2_temp.\"data\", mt_doc_invoice2_temp.\"mt_version\", mt_doc_invoice2_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice2_temp left join strong_typed1.mt_doc_invoice2 on mt_doc_invoice2_temp.id = strong_typed1.mt_doc_invoice2.id where strong_typed1.mt_doc_invoice2.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed1.mt_doc_invoice2 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice2_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice2_temp (like strong_typed1.mt_doc_invoice2 including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Invoice2 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: Invoice2BulkLoader479877131 + + + // START: Invoice2Provider479877131 + public class Invoice2Provider479877131 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Invoice2Provider479877131(Marten.Schema.DocumentMapping mapping) : base(new Invoice2BulkLoader479877131(new QueryOnlyInvoice2DocumentStorage479877131(mapping)), new QueryOnlyInvoice2DocumentStorage479877131(mapping), new LightweightInvoice2DocumentStorage479877131(mapping), new IdentityMapInvoice2DocumentStorage479877131(mapping), new DirtyTrackingInvoice2DocumentStorage479877131(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Invoice2Provider479877131 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice3Provider479877132.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice3Provider479877132.cs new file mode 100644 index 0000000000..0fbebe0819 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Invoice3Provider479877132.cs @@ -0,0 +1,826 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoice3Operation479877132 + public class UpsertInvoice3Operation479877132 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice3 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoice3Operation479877132(ValueTypeTests.StrongTypedId.Invoice3 document, ValueTypeTests.StrongTypedId.Invoice2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed21.mt_upsert_invoice3("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertInvoice3Operation479877132 + + + // START: InsertInvoice3Operation479877132 + public class InsertInvoice3Operation479877132 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice3 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoice3Operation479877132(ValueTypeTests.StrongTypedId.Invoice3 document, ValueTypeTests.StrongTypedId.Invoice2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed21.mt_insert_invoice3("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertInvoice3Operation479877132 + + + // START: UpdateInvoice3Operation479877132 + public class UpdateInvoice3Operation479877132 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Invoice3 _document; + private readonly ValueTypeTests.StrongTypedId.Invoice2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoice3Operation479877132(ValueTypeTests.StrongTypedId.Invoice3 document, ValueTypeTests.StrongTypedId.Invoice2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed21.mt_update_invoice3("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateInvoice3Operation479877132 + + + // START: QueryOnlyInvoice3Selector479877132 + public class QueryOnlyInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoice3Selector479877132 + + + // START: LightweightInvoice3Selector479877132 + public class LightweightInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoice3Selector479877132 + + + // START: IdentityMapInvoice3Selector479877132 + public class IdentityMapInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoice3Selector479877132 + + + // START: DirtyTrackingInvoice3Selector479877132 + public class DirtyTrackingInvoice3Selector479877132 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoice3Selector479877132(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Invoice3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Invoice2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Invoice3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoice3Selector479877132 + + + // START: QueryOnlyInvoice3DocumentStorage479877132 + public class QueryOnlyInvoice3DocumentStorage479877132 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyInvoice3DocumentStorage479877132 + + + // START: LightweightInvoice3DocumentStorage479877132 + public class LightweightInvoice3DocumentStorage479877132 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightInvoice3DocumentStorage479877132 + + + // START: IdentityMapInvoice3DocumentStorage479877132 + public class IdentityMapInvoice3DocumentStorage479877132 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapInvoice3DocumentStorage479877132 + + + // START: DirtyTrackingInvoice3DocumentStorage479877132 + public class DirtyTrackingInvoice3DocumentStorage479877132 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoice3DocumentStorage479877132(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Invoice2Id AssignIdentity(ValueTypeTests.StrongTypedId.Invoice3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id.Value == default) _setter(document, new ValueTypeTests.StrongTypedId.Invoice2Id(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoice3Operation479877132 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Invoice2Id Identity(ValueTypeTests.StrongTypedId.Invoice3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoice3Selector479877132(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Invoice2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Invoice2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingInvoice3DocumentStorage479877132 + + + // START: Invoice3BulkLoader479877132 + public class Invoice3BulkLoader479877132 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Invoice3BulkLoader479877132(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed21.mt_doc_invoice3(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice3_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed21.mt_doc_invoice3 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice3_temp.\"id\", mt_doc_invoice3_temp.\"data\", mt_doc_invoice3_temp.\"mt_version\", mt_doc_invoice3_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice3_temp left join strong_typed21.mt_doc_invoice3 on mt_doc_invoice3_temp.id = strong_typed21.mt_doc_invoice3.id where strong_typed21.mt_doc_invoice3.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed21.mt_doc_invoice3 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice3_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice3_temp (like strong_typed21.mt_doc_invoice3 including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Invoice3 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: Invoice3BulkLoader479877132 + + + // START: Invoice3Provider479877132 + public class Invoice3Provider479877132 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Invoice3Provider479877132(Marten.Schema.DocumentMapping mapping) : base(new Invoice3BulkLoader479877132(new QueryOnlyInvoice3DocumentStorage479877132(mapping)), new QueryOnlyInvoice3DocumentStorage479877132(mapping), new LightweightInvoice3DocumentStorage479877132(mapping), new IdentityMapInvoice3DocumentStorage479877132(mapping), new DirtyTrackingInvoice3DocumentStorage479877132(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Invoice3Provider479877132 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/InvoiceProvider1421447552.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/InvoiceProvider1421447552.cs new file mode 100644 index 0000000000..43047f7559 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/InvoiceProvider1421447552.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.Vogen; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertInvoiceOperation1421447552 + public class UpsertInvoiceOperation1421447552 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Vogen.Invoice _document; + private readonly ValueTypeTests.Vogen.InvoiceId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertInvoiceOperation1421447552(ValueTypeTests.Vogen.Invoice document, ValueTypeTests.Vogen.InvoiceId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed5.mt_upsert_invoice("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertInvoiceOperation1421447552 + + + // START: InsertInvoiceOperation1421447552 + public class InsertInvoiceOperation1421447552 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Vogen.Invoice _document; + private readonly ValueTypeTests.Vogen.InvoiceId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertInvoiceOperation1421447552(ValueTypeTests.Vogen.Invoice document, ValueTypeTests.Vogen.InvoiceId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed5.mt_insert_invoice("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertInvoiceOperation1421447552 + + + // START: UpdateInvoiceOperation1421447552 + public class UpdateInvoiceOperation1421447552 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Vogen.Invoice _document; + private readonly ValueTypeTests.Vogen.InvoiceId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateInvoiceOperation1421447552(ValueTypeTests.Vogen.Invoice document, ValueTypeTests.Vogen.InvoiceId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed5.mt_update_invoice("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateInvoiceOperation1421447552 + + + // START: QueryOnlyInvoiceSelector1421447552 + public class QueryOnlyInvoiceSelector1421447552 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyInvoiceSelector1421447552(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Vogen.Invoice document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Vogen.Invoice document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyInvoiceSelector1421447552 + + + // START: LightweightInvoiceSelector1421447552 + public class LightweightInvoiceSelector1421447552 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightInvoiceSelector1421447552(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.Vogen.InvoiceId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Vogen.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.Vogen.InvoiceId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Vogen.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightInvoiceSelector1421447552 + + + // START: IdentityMapInvoiceSelector1421447552 + public class IdentityMapInvoiceSelector1421447552 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapInvoiceSelector1421447552(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.Vogen.InvoiceId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.Vogen.InvoiceId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapInvoiceSelector1421447552 + + + // START: DirtyTrackingInvoiceSelector1421447552 + public class DirtyTrackingInvoiceSelector1421447552 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingInvoiceSelector1421447552(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Invoice Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.Vogen.InvoiceId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Invoice document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.Vogen.InvoiceId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Invoice document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingInvoiceSelector1421447552 + + + // START: QueryOnlyInvoiceDocumentStorage1421447552 + public class QueryOnlyInvoiceDocumentStorage1421447552 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyInvoiceDocumentStorage1421447552(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.InvoiceId AssignIdentity(ValueTypeTests.Vogen.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.Vogen.InvoiceId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.InvoiceId Identity(ValueTypeTests.Vogen.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyInvoiceSelector1421447552(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyInvoiceDocumentStorage1421447552 + + + // START: LightweightInvoiceDocumentStorage1421447552 + public class LightweightInvoiceDocumentStorage1421447552 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightInvoiceDocumentStorage1421447552(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.InvoiceId AssignIdentity(ValueTypeTests.Vogen.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.Vogen.InvoiceId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.InvoiceId Identity(ValueTypeTests.Vogen.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightInvoiceSelector1421447552(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightInvoiceDocumentStorage1421447552 + + + // START: IdentityMapInvoiceDocumentStorage1421447552 + public class IdentityMapInvoiceDocumentStorage1421447552 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapInvoiceDocumentStorage1421447552(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.InvoiceId AssignIdentity(ValueTypeTests.Vogen.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.Vogen.InvoiceId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.InvoiceId Identity(ValueTypeTests.Vogen.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapInvoiceSelector1421447552(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapInvoiceDocumentStorage1421447552 + + + // START: DirtyTrackingInvoiceDocumentStorage1421447552 + public class DirtyTrackingInvoiceDocumentStorage1421447552 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingInvoiceDocumentStorage1421447552(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.InvoiceId AssignIdentity(ValueTypeTests.Vogen.Invoice document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.Vogen.InvoiceId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertInvoiceOperation1421447552 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Invoice document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.InvoiceId Identity(ValueTypeTests.Vogen.Invoice document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingInvoiceSelector1421447552(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.InvoiceId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.InvoiceId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingInvoiceDocumentStorage1421447552 + + + // START: InvoiceBulkLoader1421447552 + public class InvoiceBulkLoader1421447552 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public InvoiceBulkLoader1421447552(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed5.mt_doc_invoice(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_invoice_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed5.mt_doc_invoice (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_invoice_temp.\"id\", mt_doc_invoice_temp.\"data\", mt_doc_invoice_temp.\"mt_version\", mt_doc_invoice_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_invoice_temp left join strong_typed5.mt_doc_invoice on mt_doc_invoice_temp.id = strong_typed5.mt_doc_invoice.id where strong_typed5.mt_doc_invoice.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed5.mt_doc_invoice target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_invoice_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_invoice_temp (like strong_typed5.mt_doc_invoice including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Vogen.Invoice document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Vogen.Invoice document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: InvoiceBulkLoader1421447552 + + + // START: InvoiceProvider1421447552 + public class InvoiceProvider1421447552 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public InvoiceProvider1421447552(Marten.Schema.DocumentMapping mapping) : base(new InvoiceBulkLoader1421447552(new QueryOnlyInvoiceDocumentStorage1421447552(mapping)), new QueryOnlyInvoiceDocumentStorage1421447552(mapping), new LightweightInvoiceDocumentStorage1421447552(mapping), new IdentityMapInvoiceDocumentStorage1421447552(mapping), new DirtyTrackingInvoiceDocumentStorage1421447552(mapping)) + { + _mapping = mapping; + } + + + } + + // END: InvoiceProvider1421447552 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/OrderProvider347010495.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/OrderProvider347010495.cs new file mode 100644 index 0000000000..2177d2cc36 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/OrderProvider347010495.cs @@ -0,0 +1,854 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertOrderOperation347010495 + public class UpsertOrderOperation347010495 : Marten.Internal.Operations.StorageOperation + { + private readonly FSharpTypes.Order _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertOrderOperation347010495(FSharpTypes.Order document, FSharpTypes.OrderId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, FSharpTypes.Order document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_upsert_fsharptypes_order("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertOrderOperation347010495 + + + // START: InsertOrderOperation347010495 + public class InsertOrderOperation347010495 : Marten.Internal.Operations.StorageOperation + { + private readonly FSharpTypes.Order _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertOrderOperation347010495(FSharpTypes.Order document, FSharpTypes.OrderId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, FSharpTypes.Order document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_insert_fsharptypes_order("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertOrderOperation347010495 + + + // START: UpdateOrderOperation347010495 + public class UpdateOrderOperation347010495 : Marten.Internal.Operations.StorageOperation + { + private readonly FSharpTypes.Order _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateOrderOperation347010495(FSharpTypes.Order document, FSharpTypes.OrderId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, FSharpTypes.Order document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_update_fsharptypes_order("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateOrderOperation347010495 + + + // START: QueryOnlyOrderSelector347010495 + public class QueryOnlyOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyOrderSelector347010495 + + + // START: LightweightOrderSelector347010495 + public class LightweightOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightOrderSelector347010495 + + + // START: IdentityMapOrderSelector347010495 + public class IdentityMapOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapOrderSelector347010495 + + + // START: DirtyTrackingOrderSelector347010495 + public class DirtyTrackingOrderSelector347010495 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingOrderSelector347010495(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public FSharpTypes.Order Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + FSharpTypes.Order document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingOrderSelector347010495 + + + // START: QueryOnlyOrderDocumentStorage347010495 + public class QueryOnlyOrderDocumentStorage347010495 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyOrderDocumentStorage347010495 + + + // START: LightweightOrderDocumentStorage347010495 + public class LightweightOrderDocumentStorage347010495 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightOrderDocumentStorage347010495 + + + // START: IdentityMapOrderDocumentStorage347010495 + public class IdentityMapOrderDocumentStorage347010495 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapOrderDocumentStorage347010495 + + + // START: DirtyTrackingOrderDocumentStorage347010495 + public class DirtyTrackingOrderDocumentStorage347010495 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingOrderDocumentStorage347010495(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(FSharpTypes.Order document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertOrderOperation347010495 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(FSharpTypes.Order document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(FSharpTypes.Order document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingOrderSelector347010495(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingOrderDocumentStorage347010495 + + + // START: OrderBulkLoader347010495 + public class OrderBulkLoader347010495 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public OrderBulkLoader347010495(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed_fsharp.mt_doc_fsharptypes_order(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_fsharptypes_order_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed_fsharp.mt_doc_fsharptypes_order (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_fsharptypes_order_temp.\"id\", mt_doc_fsharptypes_order_temp.\"data\", mt_doc_fsharptypes_order_temp.\"mt_version\", mt_doc_fsharptypes_order_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_fsharptypes_order_temp left join strong_typed_fsharp.mt_doc_fsharptypes_order on mt_doc_fsharptypes_order_temp.id = strong_typed_fsharp.mt_doc_fsharptypes_order.id where strong_typed_fsharp.mt_doc_fsharptypes_order.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed_fsharp.mt_doc_fsharptypes_order target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_fsharptypes_order_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_fsharptypes_order_temp (like strong_typed_fsharp.mt_doc_fsharptypes_order including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, FSharpTypes.Order document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Item, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, FSharpTypes.Order document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Item, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: OrderBulkLoader347010495 + + + // START: OrderProvider347010495 + public class OrderProvider347010495 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public OrderProvider347010495(Marten.Schema.DocumentMapping mapping) : base(new OrderBulkLoader347010495(new QueryOnlyOrderDocumentStorage347010495(mapping)), new QueryOnlyOrderDocumentStorage347010495(mapping), new LightweightOrderDocumentStorage347010495(mapping), new IdentityMapOrderDocumentStorage347010495(mapping), new DirtyTrackingOrderDocumentStorage347010495(mapping)) + { + _mapping = mapping; + } + + + } + + // END: OrderProvider347010495 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/ReferenceTypeOrderProvider1892982689.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ReferenceTypeOrderProvider1892982689.cs new file mode 100644 index 0000000000..81ff20caff --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/ReferenceTypeOrderProvider1892982689.cs @@ -0,0 +1,855 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertReferenceTypeOrderOperation1892982689 + public class UpsertReferenceTypeOrderOperation1892982689 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.ReferenceTypeOrder _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertReferenceTypeOrderOperation1892982689(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, FSharpTypes.OrderId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_upsert_referencetypeorder("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertReferenceTypeOrderOperation1892982689 + + + // START: InsertReferenceTypeOrderOperation1892982689 + public class InsertReferenceTypeOrderOperation1892982689 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.ReferenceTypeOrder _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertReferenceTypeOrderOperation1892982689(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, FSharpTypes.OrderId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_insert_referencetypeorder("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertReferenceTypeOrderOperation1892982689 + + + // START: UpdateReferenceTypeOrderOperation1892982689 + public class UpdateReferenceTypeOrderOperation1892982689 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.ReferenceTypeOrder _document; + private readonly FSharpTypes.OrderId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateReferenceTypeOrderOperation1892982689(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, FSharpTypes.OrderId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed_fsharp.mt_update_referencetypeorder("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Item); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateReferenceTypeOrderOperation1892982689 + + + // START: QueryOnlyReferenceTypeOrderSelector1892982689 + public class QueryOnlyReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyReferenceTypeOrderSelector1892982689 + + + // START: LightweightReferenceTypeOrderSelector1892982689 + public class LightweightReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightReferenceTypeOrderSelector1892982689 + + + // START: IdentityMapReferenceTypeOrderSelector1892982689 + public class IdentityMapReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapReferenceTypeOrderSelector1892982689 + + + // START: DirtyTrackingReferenceTypeOrderSelector1892982689 + public class DirtyTrackingReferenceTypeOrderSelector1892982689 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingReferenceTypeOrderSelector1892982689(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.ReferenceTypeOrder Resolve(System.Data.Common.DbDataReader reader) + { + var id = FSharpTypes.OrderId.NewId(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = FSharpTypes.OrderId.NewId(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.ReferenceTypeOrder document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingReferenceTypeOrderSelector1892982689 + + + // START: QueryOnlyReferenceTypeOrderDocumentStorage1892982689 + public class QueryOnlyReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyReferenceTypeOrderDocumentStorage1892982689 + + + // START: LightweightReferenceTypeOrderDocumentStorage1892982689 + public class LightweightReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightReferenceTypeOrderDocumentStorage1892982689 + + + // START: IdentityMapReferenceTypeOrderDocumentStorage1892982689 + public class IdentityMapReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapReferenceTypeOrderDocumentStorage1892982689 + + + // START: DirtyTrackingReferenceTypeOrderDocumentStorage1892982689 + public class DirtyTrackingReferenceTypeOrderDocumentStorage1892982689 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingReferenceTypeOrderDocumentStorage1892982689(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override FSharpTypes.OrderId AssignIdentity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertReferenceTypeOrderOperation1892982689 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override FSharpTypes.OrderId Identity(ValueTypeTests.StrongTypedId.ReferenceTypeOrder document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingReferenceTypeOrderSelector1892982689(session, _document); + } + + + public override object RawIdentityValue(FSharpTypes.OrderId id) + { + return id.Item; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(FSharpTypes.OrderId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Item)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingReferenceTypeOrderDocumentStorage1892982689 + + + // START: ReferenceTypeOrderBulkLoader1892982689 + public class ReferenceTypeOrderBulkLoader1892982689 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public ReferenceTypeOrderBulkLoader1892982689(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed_fsharp.mt_doc_referencetypeorder(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_referencetypeorder_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed_fsharp.mt_doc_referencetypeorder (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_referencetypeorder_temp.\"id\", mt_doc_referencetypeorder_temp.\"data\", mt_doc_referencetypeorder_temp.\"mt_version\", mt_doc_referencetypeorder_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_referencetypeorder_temp left join strong_typed_fsharp.mt_doc_referencetypeorder on mt_doc_referencetypeorder_temp.id = strong_typed_fsharp.mt_doc_referencetypeorder.id where strong_typed_fsharp.mt_doc_referencetypeorder.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed_fsharp.mt_doc_referencetypeorder target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_referencetypeorder_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_referencetypeorder_temp (like strong_typed_fsharp.mt_doc_referencetypeorder including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Item, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.ReferenceTypeOrder document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Item, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: ReferenceTypeOrderBulkLoader1892982689 + + + // START: ReferenceTypeOrderProvider1892982689 + public class ReferenceTypeOrderProvider1892982689 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public ReferenceTypeOrderProvider1892982689(Marten.Schema.DocumentMapping mapping) : base(new ReferenceTypeOrderBulkLoader1892982689(new QueryOnlyReferenceTypeOrderDocumentStorage1892982689(mapping)), new QueryOnlyReferenceTypeOrderDocumentStorage1892982689(mapping), new LightweightReferenceTypeOrderDocumentStorage1892982689(mapping), new IdentityMapReferenceTypeOrderDocumentStorage1892982689(mapping), new DirtyTrackingReferenceTypeOrderDocumentStorage1892982689(mapping)) + { + _mapping = mapping; + } + + + } + + // END: ReferenceTypeOrderProvider1892982689 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeacherProvider944571072.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeacherProvider944571072.cs new file mode 100644 index 0000000000..15b9549413 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeacherProvider944571072.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeacherOperation944571072 + public class UpsertTeacherOperation944571072 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Teacher _document; + private readonly ValueTypeTests.TeacherId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeacherOperation944571072(ValueTypeTests.Teacher document, ValueTypeTests.TeacherId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_upsert_teacher("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeacherOperation944571072 + + + // START: InsertTeacherOperation944571072 + public class InsertTeacherOperation944571072 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Teacher _document; + private readonly ValueTypeTests.TeacherId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeacherOperation944571072(ValueTypeTests.Teacher document, ValueTypeTests.TeacherId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_insert_teacher("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeacherOperation944571072 + + + // START: UpdateTeacherOperation944571072 + public class UpdateTeacherOperation944571072 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Teacher _document; + private readonly ValueTypeTests.TeacherId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeacherOperation944571072(ValueTypeTests.Teacher document, ValueTypeTests.TeacherId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Uuid; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed24.mt_update_teacher("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Uuid; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeacherOperation944571072 + + + // START: QueryOnlyTeacherSelector944571072 + public class QueryOnlyTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeacherSelector944571072 + + + // START: LightweightTeacherSelector944571072 + public class LightweightTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.TeacherId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.TeacherId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeacherSelector944571072 + + + // START: IdentityMapTeacherSelector944571072 + public class IdentityMapTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.TeacherId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.TeacherId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeacherSelector944571072 + + + // START: DirtyTrackingTeacherSelector944571072 + public class DirtyTrackingTeacherSelector944571072 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeacherSelector944571072(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Teacher Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.TeacherId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.TeacherId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Teacher document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeacherSelector944571072 + + + // START: QueryOnlyTeacherDocumentStorage944571072 + public class QueryOnlyTeacherDocumentStorage944571072 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: QueryOnlyTeacherDocumentStorage944571072 + + + // START: LightweightTeacherDocumentStorage944571072 + public class LightweightTeacherDocumentStorage944571072 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: LightweightTeacherDocumentStorage944571072 + + + // START: IdentityMapTeacherDocumentStorage944571072 + public class IdentityMapTeacherDocumentStorage944571072 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: IdentityMapTeacherDocumentStorage944571072 + + + // START: DirtyTrackingTeacherDocumentStorage944571072 + public class DirtyTrackingTeacherDocumentStorage944571072 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeacherDocumentStorage944571072(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.TeacherId AssignIdentity(ValueTypeTests.Teacher document, string tenantId, Marten.Storage.IMartenDatabase database) + { + if (document.Id == null) _setter(document, ValueTypeTests.TeacherId.From(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid())); + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeacherOperation944571072 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Teacher document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.TeacherId Identity(ValueTypeTests.Teacher document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeacherSelector944571072(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.TeacherId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.TeacherId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Uuid}; + } + + } + + // END: DirtyTrackingTeacherDocumentStorage944571072 + + + // START: TeacherBulkLoader944571072 + public class TeacherBulkLoader944571072 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public TeacherBulkLoader944571072(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed24.mt_doc_teacher(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_teacher_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed24.mt_doc_teacher (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_teacher_temp.\"id\", mt_doc_teacher_temp.\"data\", mt_doc_teacher_temp.\"mt_version\", mt_doc_teacher_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_teacher_temp left join strong_typed24.mt_doc_teacher on mt_doc_teacher_temp.id = strong_typed24.mt_doc_teacher.id where strong_typed24.mt_doc_teacher.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed24.mt_doc_teacher target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_teacher_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_teacher_temp (like strong_typed24.mt_doc_teacher including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Teacher document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Teacher document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: TeacherBulkLoader944571072 + + + // START: TeacherProvider944571072 + public class TeacherProvider944571072 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public TeacherProvider944571072(Marten.Schema.DocumentMapping mapping) : base(new TeacherBulkLoader944571072(new QueryOnlyTeacherDocumentStorage944571072(mapping)), new QueryOnlyTeacherDocumentStorage944571072(mapping), new LightweightTeacherDocumentStorage944571072(mapping), new IdentityMapTeacherDocumentStorage944571072(mapping), new DirtyTrackingTeacherDocumentStorage944571072(mapping)) + { + _mapping = mapping; + } + + + } + + // END: TeacherProvider944571072 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team2Provider1170066519.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team2Provider1170066519.cs new file mode 100644 index 0000000000..7bcd7b4bb9 --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team2Provider1170066519.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeam2Operation1170066519 + public class UpsertTeam2Operation1170066519 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team2 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeam2Operation1170066519(ValueTypeTests.StrongTypedId.Team2 document, ValueTypeTests.StrongTypedId.Team2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed4.mt_upsert_team2("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeam2Operation1170066519 + + + // START: InsertTeam2Operation1170066519 + public class InsertTeam2Operation1170066519 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team2 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeam2Operation1170066519(ValueTypeTests.StrongTypedId.Team2 document, ValueTypeTests.StrongTypedId.Team2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed4.mt_insert_team2("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeam2Operation1170066519 + + + // START: UpdateTeam2Operation1170066519 + public class UpdateTeam2Operation1170066519 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team2 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeam2Operation1170066519(ValueTypeTests.StrongTypedId.Team2 document, ValueTypeTests.StrongTypedId.Team2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed4.mt_update_team2("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeam2Operation1170066519 + + + // START: QueryOnlyTeam2Selector1170066519 + public class QueryOnlyTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeam2Selector1170066519 + + + // START: LightweightTeam2Selector1170066519 + public class LightweightTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeam2Selector1170066519 + + + // START: IdentityMapTeam2Selector1170066519 + public class IdentityMapTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeam2Selector1170066519 + + + // START: DirtyTrackingTeam2Selector1170066519 + public class DirtyTrackingTeam2Selector1170066519 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeam2Selector1170066519(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team2 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team2 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeam2Selector1170066519 + + + // START: QueryOnlyTeam2DocumentStorage1170066519 + public class QueryOnlyTeam2DocumentStorage1170066519 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: QueryOnlyTeam2DocumentStorage1170066519 + + + // START: LightweightTeam2DocumentStorage1170066519 + public class LightweightTeam2DocumentStorage1170066519 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: LightweightTeam2DocumentStorage1170066519 + + + // START: IdentityMapTeam2DocumentStorage1170066519 + public class IdentityMapTeam2DocumentStorage1170066519 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: IdentityMapTeam2DocumentStorage1170066519 + + + // START: DirtyTrackingTeam2DocumentStorage1170066519 + public class DirtyTrackingTeam2DocumentStorage1170066519 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeam2DocumentStorage1170066519(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team2 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam2Operation1170066519 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team2 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team2 document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeam2Selector1170066519(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: DirtyTrackingTeam2DocumentStorage1170066519 + + + // START: Team2BulkLoader1170066519 + public class Team2BulkLoader1170066519 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Team2BulkLoader1170066519(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed4.mt_doc_team2(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_team2_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed4.mt_doc_team2 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_team2_temp.\"id\", mt_doc_team2_temp.\"data\", mt_doc_team2_temp.\"mt_version\", mt_doc_team2_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_team2_temp left join strong_typed4.mt_doc_team2 on mt_doc_team2_temp.id = strong_typed4.mt_doc_team2.id where strong_typed4.mt_doc_team2.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed4.mt_doc_team2 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_team2_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_team2_temp (like strong_typed4.mt_doc_team2 including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Team2 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Text); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Team2 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Text, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: Team2BulkLoader1170066519 + + + // START: Team2Provider1170066519 + public class Team2Provider1170066519 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Team2Provider1170066519(Marten.Schema.DocumentMapping mapping) : base(new Team2BulkLoader1170066519(new QueryOnlyTeam2DocumentStorage1170066519(mapping)), new QueryOnlyTeam2DocumentStorage1170066519(mapping), new LightweightTeam2DocumentStorage1170066519(mapping), new IdentityMapTeam2DocumentStorage1170066519(mapping), new DirtyTrackingTeam2DocumentStorage1170066519(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Team2Provider1170066519 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team3Provider396017422.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team3Provider396017422.cs new file mode 100644 index 0000000000..bc8ea1495e --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/Team3Provider396017422.cs @@ -0,0 +1,826 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.StrongTypedId; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeam3Operation396017422 + public class UpsertTeam3Operation396017422 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team3 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeam3Operation396017422(ValueTypeTests.StrongTypedId.Team3 document, ValueTypeTests.StrongTypedId.Team2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed23.mt_upsert_team3("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeam3Operation396017422 + + + // START: InsertTeam3Operation396017422 + public class InsertTeam3Operation396017422 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team3 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeam3Operation396017422(ValueTypeTests.StrongTypedId.Team3 document, ValueTypeTests.StrongTypedId.Team2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed23.mt_insert_team3("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeam3Operation396017422 + + + // START: UpdateTeam3Operation396017422 + public class UpdateTeam3Operation396017422 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.StrongTypedId.Team3 _document; + private readonly ValueTypeTests.StrongTypedId.Team2Id _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeam3Operation396017422(ValueTypeTests.StrongTypedId.Team3 document, ValueTypeTests.StrongTypedId.Team2Id id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed23.mt_update_team3("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value); + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeam3Operation396017422 + + + // START: QueryOnlyTeam3Selector396017422 + public class QueryOnlyTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeam3Selector396017422 + + + // START: LightweightTeam3Selector396017422 + public class LightweightTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeam3Selector396017422 + + + // START: IdentityMapTeam3Selector396017422 + public class IdentityMapTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeam3Selector396017422 + + + // START: DirtyTrackingTeam3Selector396017422 + public class DirtyTrackingTeam3Selector396017422 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeam3Selector396017422(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.StrongTypedId.Team3 Resolve(System.Data.Common.DbDataReader reader) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = new ValueTypeTests.StrongTypedId.Team2Id(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.StrongTypedId.Team3 document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeam3Selector396017422 + + + // START: QueryOnlyTeam3DocumentStorage396017422 + public class QueryOnlyTeam3DocumentStorage396017422 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: QueryOnlyTeam3DocumentStorage396017422 + + + // START: LightweightTeam3DocumentStorage396017422 + public class LightweightTeam3DocumentStorage396017422 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: LightweightTeam3DocumentStorage396017422 + + + // START: IdentityMapTeam3DocumentStorage396017422 + public class IdentityMapTeam3DocumentStorage396017422 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: IdentityMapTeam3DocumentStorage396017422 + + + // START: DirtyTrackingTeam3DocumentStorage396017422 + public class DirtyTrackingTeam3DocumentStorage396017422 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeam3DocumentStorage396017422(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.StrongTypedId.Team2Id AssignIdentity(ValueTypeTests.StrongTypedId.Team3 document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id; + return document.Id; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeam3Operation396017422 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.StrongTypedId.Team3 document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.StrongTypedId.Team2Id Identity(ValueTypeTests.StrongTypedId.Team3 document) + { + return document.Id; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeam3Selector396017422(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.StrongTypedId.Team2Id id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.StrongTypedId.Team2Id[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: DirtyTrackingTeam3DocumentStorage396017422 + + + // START: Team3BulkLoader396017422 + public class Team3BulkLoader396017422 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public Team3BulkLoader396017422(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed23.mt_doc_team3(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_team3_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed23.mt_doc_team3 (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_team3_temp.\"id\", mt_doc_team3_temp.\"data\", mt_doc_team3_temp.\"mt_version\", mt_doc_team3_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_team3_temp left join strong_typed23.mt_doc_team3 on mt_doc_team3_temp.id = strong_typed23.mt_doc_team3.id where strong_typed23.mt_doc_team3.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed23.mt_doc_team3 target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_team3_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_team3_temp (like strong_typed23.mt_doc_team3 including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Team3 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value, NpgsqlTypes.NpgsqlDbType.Text); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.StrongTypedId.Team3 document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value, NpgsqlTypes.NpgsqlDbType.Text, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: Team3BulkLoader396017422 + + + // START: Team3Provider396017422 + public class Team3Provider396017422 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public Team3Provider396017422(Marten.Schema.DocumentMapping mapping) : base(new Team3BulkLoader396017422(new QueryOnlyTeam3DocumentStorage396017422(mapping)), new QueryOnlyTeam3DocumentStorage396017422(mapping), new LightweightTeam3DocumentStorage396017422(mapping), new IdentityMapTeam3DocumentStorage396017422(mapping), new DirtyTrackingTeam3DocumentStorage396017422(mapping)) + { + _mapping = mapping; + } + + + } + + // END: Team3Provider396017422 + + +} + diff --git a/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeamProvider389145516.cs b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeamProvider389145516.cs new file mode 100644 index 0000000000..402a82ff5f --- /dev/null +++ b/src/ValueTypeTests/Internal/Generated/DocumentStorage/TeamProvider389145516.cs @@ -0,0 +1,859 @@ +// +#pragma warning disable +using Marten.Internal; +using Marten.Internal.Storage; +using Marten.Schema; +using Marten.Schema.Arguments; +using Npgsql; +using System.Collections.Generic; +using ValueTypeTests.Vogen; +using Weasel.Core; +using Weasel.Postgresql; + +namespace Marten.Generated.DocumentStorage +{ + // START: UpsertTeamOperation389145516 + public class UpsertTeamOperation389145516 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Vogen.Team _document; + private readonly ValueTypeTests.Vogen.TeamId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpsertTeamOperation389145516(ValueTypeTests.Vogen.Team document, ValueTypeTests.Vogen.TeamId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Upsert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed8.mt_upsert_team("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpsertTeamOperation389145516 + + + // START: InsertTeamOperation389145516 + public class InsertTeamOperation389145516 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Vogen.Team _document; + private readonly ValueTypeTests.Vogen.TeamId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public InsertTeamOperation389145516(ValueTypeTests.Vogen.Team document, ValueTypeTests.Vogen.TeamId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + } + + + public override System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + // Nothing + return System.Threading.Tasks.Task.CompletedTask; + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Insert; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed8.mt_insert_team("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: InsertTeamOperation389145516 + + + // START: UpdateTeamOperation389145516 + public class UpdateTeamOperation389145516 : Marten.Internal.Operations.StorageOperation + { + private readonly ValueTypeTests.Vogen.Team _document; + private readonly ValueTypeTests.Vogen.TeamId _id; + private readonly System.Collections.Generic.Dictionary _versions; + private readonly Marten.Schema.DocumentMapping _mapping; + + public UpdateTeamOperation389145516(ValueTypeTests.Vogen.Team document, ValueTypeTests.Vogen.TeamId id, System.Collections.Generic.Dictionary versions, Marten.Schema.DocumentMapping mapping) : base(document, id, versions, mapping) + { + _document = document; + _id = id; + _versions = versions; + _mapping = mapping; + } + + + + public override void Postprocess(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions) + { + storeVersion(); + postprocessUpdate(reader, exceptions); + } + + + public override async System.Threading.Tasks.Task PostprocessAsync(System.Data.Common.DbDataReader reader, System.Collections.Generic.IList exceptions, System.Threading.CancellationToken token) + { + storeVersion(); + await postprocessUpdateAsync(reader, exceptions, token); + } + + + public override Marten.Internal.Operations.OperationRole Role() + { + return Marten.Internal.Operations.OperationRole.Update; + } + + + public override NpgsqlTypes.NpgsqlDbType DbType() + { + return NpgsqlTypes.NpgsqlDbType.Text; + } + + + public override void ConfigureParameters(Weasel.Postgresql.IGroupedParameterBuilder parameterBuilder, Weasel.Postgresql.ICommandBuilder builder, ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session) + { + builder.Append("select strong_typed8.mt_update_team("); + var parameter0 = parameterBuilder.AppendParameter(session.Serializer.ToJson(_document)); + parameter0.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Jsonb; + // .Net Class Type + var parameter1 = parameterBuilder.AppendParameter(_document.GetType().FullName); + parameter1.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Varchar; + + if (document.Id != null) + { + var parameter2 = parameterBuilder.AppendParameter(document.Id.Value.Value); + parameter2.NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Text; + } + + else + { + var parameter2 = parameterBuilder.AppendParameter(System.DBNull.Value); + } + + setVersionParameter(parameterBuilder); + builder.Append(')'); + } + + } + + // END: UpdateTeamOperation389145516 + + + // START: QueryOnlyTeamSelector389145516 + public class QueryOnlyTeamSelector389145516 : Marten.Internal.CodeGeneration.DocumentSelectorWithOnlySerializer, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public QueryOnlyTeamSelector389145516(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Team Resolve(System.Data.Common.DbDataReader reader) + { + + ValueTypeTests.Vogen.Team document; + document = _serializer.FromJson(reader, 0); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + + ValueTypeTests.Vogen.Team document; + document = await _serializer.FromJsonAsync(reader, 0, token).ConfigureAwait(false); + return document; + } + + } + + // END: QueryOnlyTeamSelector389145516 + + + // START: LightweightTeamSelector389145516 + public class LightweightTeamSelector389145516 : Marten.Internal.CodeGeneration.DocumentSelectorWithVersions, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public LightweightTeamSelector389145516(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Team Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.Vogen.TeamId.From(reader.GetFieldValue(0)); + + ValueTypeTests.Vogen.Team document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.Vogen.TeamId.From(await reader.GetFieldValueAsync(0, token)); + + ValueTypeTests.Vogen.Team document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + return document; + } + + } + + // END: LightweightTeamSelector389145516 + + + // START: IdentityMapTeamSelector389145516 + public class IdentityMapTeamSelector389145516 : Marten.Internal.CodeGeneration.DocumentSelectorWithIdentityMap, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public IdentityMapTeamSelector389145516(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Team Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.Vogen.TeamId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Team document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.Vogen.TeamId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Team document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + return document; + } + + } + + // END: IdentityMapTeamSelector389145516 + + + // START: DirtyTrackingTeamSelector389145516 + public class DirtyTrackingTeamSelector389145516 : Marten.Internal.CodeGeneration.DocumentSelectorWithDirtyChecking, Marten.Linq.Selectors.ISelector + { + private readonly Marten.Internal.IMartenSession _session; + private readonly Marten.Schema.DocumentMapping _mapping; + + public DirtyTrackingTeamSelector389145516(Marten.Internal.IMartenSession session, Marten.Schema.DocumentMapping mapping) : base(session, mapping) + { + _session = session; + _mapping = mapping; + } + + + + public ValueTypeTests.Vogen.Team Resolve(System.Data.Common.DbDataReader reader) + { + var id = ValueTypeTests.Vogen.TeamId.From(reader.GetFieldValue(0)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Team document; + document = _serializer.FromJson(reader, 1); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + + public async System.Threading.Tasks.Task ResolveAsync(System.Data.Common.DbDataReader reader, System.Threading.CancellationToken token) + { + var id = ValueTypeTests.Vogen.TeamId.From(await reader.GetFieldValueAsync(0, token)); + if (_identityMap.TryGetValue(id, out var existing)) return existing; + + ValueTypeTests.Vogen.Team document; + document = await _serializer.FromJsonAsync(reader, 1, token).ConfigureAwait(false); + _session.MarkAsDocumentLoaded(id, document); + _identityMap[id] = document; + StoreTracker(_session, document); + return document; + } + + } + + // END: DirtyTrackingTeamSelector389145516 + + + // START: QueryOnlyTeamDocumentStorage389145516 + public class QueryOnlyTeamDocumentStorage389145516 : Marten.Internal.Storage.QueryOnlyDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public QueryOnlyTeamDocumentStorage389145516(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.TeamId AssignIdentity(ValueTypeTests.Vogen.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.TeamId Identity(ValueTypeTests.Vogen.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.QueryOnlyTeamSelector389145516(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: QueryOnlyTeamDocumentStorage389145516 + + + // START: LightweightTeamDocumentStorage389145516 + public class LightweightTeamDocumentStorage389145516 : Marten.Internal.Storage.LightweightDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public LightweightTeamDocumentStorage389145516(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.TeamId AssignIdentity(ValueTypeTests.Vogen.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.TeamId Identity(ValueTypeTests.Vogen.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.LightweightTeamSelector389145516(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: LightweightTeamDocumentStorage389145516 + + + // START: IdentityMapTeamDocumentStorage389145516 + public class IdentityMapTeamDocumentStorage389145516 : Marten.Internal.Storage.IdentityMapDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public IdentityMapTeamDocumentStorage389145516(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.TeamId AssignIdentity(ValueTypeTests.Vogen.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.TeamId Identity(ValueTypeTests.Vogen.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.IdentityMapTeamSelector389145516(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: IdentityMapTeamDocumentStorage389145516 + + + // START: DirtyTrackingTeamDocumentStorage389145516 + public class DirtyTrackingTeamDocumentStorage389145516 : Marten.Internal.Storage.DirtyCheckedDocumentStorage + { + private readonly Marten.Schema.DocumentMapping _document; + + public DirtyTrackingTeamDocumentStorage389145516(Marten.Schema.DocumentMapping document) : base(document) + { + _document = document; + } + + + + public override ValueTypeTests.Vogen.TeamId AssignIdentity(ValueTypeTests.Vogen.Team document, string tenantId, Marten.Storage.IMartenDatabase database) + { + return document.Id.Value; + return document.Id.Value; + } + + + public override Marten.Internal.Operations.IStorageOperation Update(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpdateTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Insert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.InsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Upsert(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + + return new Marten.Generated.DocumentStorage.UpsertTeamOperation389145516 + ( + document, Identity(document), + session.Versions.ForType(), + _document + + ); + } + + + public override Marten.Internal.Operations.IStorageOperation Overwrite(ValueTypeTests.Vogen.Team document, Marten.Internal.IMartenSession session, string tenant) + { + throw new System.NotSupportedException(); + } + + + public override ValueTypeTests.Vogen.TeamId Identity(ValueTypeTests.Vogen.Team document) + { + return document.Id.Value; + } + + + public override Marten.Linq.Selectors.ISelector BuildSelector(Marten.Internal.IMartenSession session) + { + return new Marten.Generated.DocumentStorage.DirtyTrackingTeamSelector389145516(session, _document); + } + + + public override object RawIdentityValue(ValueTypeTests.Vogen.TeamId id) + { + return id.Value; + } + + + public override Npgsql.NpgsqlParameter BuildManyIdParameter(ValueTypeTests.Vogen.TeamId[] ids) + { + return new(){Value = System.Linq.Enumerable.ToArray(System.Linq.Enumerable.Select(ids, x => x.Value)), NpgsqlDbType = NpgsqlTypes.NpgsqlDbType.Array | NpgsqlTypes.NpgsqlDbType.Text}; + } + + } + + // END: DirtyTrackingTeamDocumentStorage389145516 + + + // START: TeamBulkLoader389145516 + public class TeamBulkLoader389145516 : Marten.Internal.CodeGeneration.BulkLoader + { + private readonly Marten.Internal.Storage.IDocumentStorage _storage; + + public TeamBulkLoader389145516(Marten.Internal.Storage.IDocumentStorage storage) : base(storage) + { + _storage = storage; + } + + + public const string MAIN_LOADER_SQL = "COPY strong_typed8.mt_doc_team(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string TEMP_LOADER_SQL = "COPY mt_doc_team_temp(\"mt_dotnet_type\", \"id\", \"mt_version\", \"data\") FROM STDIN BINARY"; + + public const string COPY_NEW_DOCUMENTS_SQL = "insert into strong_typed8.mt_doc_team (\"id\", \"data\", \"mt_version\", \"mt_dotnet_type\", mt_last_modified) (select mt_doc_team_temp.\"id\", mt_doc_team_temp.\"data\", mt_doc_team_temp.\"mt_version\", mt_doc_team_temp.\"mt_dotnet_type\", transaction_timestamp() from mt_doc_team_temp left join strong_typed8.mt_doc_team on mt_doc_team_temp.id = strong_typed8.mt_doc_team.id where strong_typed8.mt_doc_team.id is null)"; + + public const string OVERWRITE_SQL = "update strong_typed8.mt_doc_team target SET data = source.data, mt_version = source.mt_version, mt_dotnet_type = source.mt_dotnet_type, mt_last_modified = transaction_timestamp() FROM mt_doc_team_temp source WHERE source.id = target.id"; + + public const string CREATE_TEMP_TABLE_FOR_COPYING_SQL = "create temporary table mt_doc_team_temp (like strong_typed8.mt_doc_team including defaults)"; + + + public override string CreateTempTableForCopying() + { + return CREATE_TEMP_TABLE_FOR_COPYING_SQL; + } + + + public override string CopyNewDocumentsFromTempTable() + { + return COPY_NEW_DOCUMENTS_SQL; + } + + + public override string OverwriteDuplicatesFromTempTable() + { + return OVERWRITE_SQL; + } + + + public override void LoadRow(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Vogen.Team document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer) + { + writer.Write(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar); + writer.Write(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Text); + writer.Write(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid); + writer.Write(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb); + } + + + public override async System.Threading.Tasks.Task LoadRowAsync(Npgsql.NpgsqlBinaryImporter writer, ValueTypeTests.Vogen.Team document, Marten.Storage.Tenant tenant, Marten.ISerializer serializer, System.Threading.CancellationToken cancellation) + { + await writer.WriteAsync(document.GetType().FullName, NpgsqlTypes.NpgsqlDbType.Varchar, cancellation); + await writer.WriteAsync(document.Id.Value.Value, NpgsqlTypes.NpgsqlDbType.Text, cancellation); + await writer.WriteAsync(Marten.Schema.Identity.CombGuidIdGeneration.NewGuid(), NpgsqlTypes.NpgsqlDbType.Uuid, cancellation); + await writer.WriteAsync(serializer.ToJson(document), NpgsqlTypes.NpgsqlDbType.Jsonb, cancellation); + } + + + public override string MainLoaderSql() + { + return MAIN_LOADER_SQL; + } + + + public override string TempLoaderSql() + { + return TEMP_LOADER_SQL; + } + + } + + // END: TeamBulkLoader389145516 + + + // START: TeamProvider389145516 + public class TeamProvider389145516 : Marten.Internal.Storage.DocumentProvider + { + private readonly Marten.Schema.DocumentMapping _mapping; + + public TeamProvider389145516(Marten.Schema.DocumentMapping mapping) : base(new TeamBulkLoader389145516(new QueryOnlyTeamDocumentStorage389145516(mapping)), new QueryOnlyTeamDocumentStorage389145516(mapping), new LightweightTeamDocumentStorage389145516(mapping), new IdentityMapTeamDocumentStorage389145516(mapping), new DirtyTrackingTeamDocumentStorage389145516(mapping)) + { + _mapping = mapping; + } + + + } + + // END: TeamProvider389145516 + + +} +