Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions src/DocumentDbTests/Indexes/NgramSearchTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ public async Task test_ngram_search_returns_data()
var store = DocumentStore.For(_ =>
{
_.Connection(Marten.Testing.Harness.ConnectionSource.ConnectionString);

// This creates
_.Schema.For<User>().NgramIndex(x => x.UserName);
});

Expand Down Expand Up @@ -83,7 +81,6 @@ public async Task test_ngram_search_returns_data_using_db_schema()
var store = DocumentStore.For(_ =>
{
_.Connection(Marten.Testing.Harness.ConnectionSource.ConnectionString);

_.DatabaseSchemaName = "ngram_test";

// This creates an ngram index for efficient sub string based matching
Expand Down Expand Up @@ -118,11 +115,10 @@ public async Task test_ngram_search_returns_data_using_db_schema()

[Fact]
public async Task test_ngram_on_nested_prop_search_returns_data()
{
{
var store = DocumentStore.For(_ =>
{
_.Connection(Marten.Testing.Harness.ConnectionSource.ConnectionString);

// This creates
_.Schema.For<User>().NgramIndex(x => x.Address.Line1);
});
Expand Down Expand Up @@ -164,8 +160,6 @@ public async Task test_ngram_when_using_non_ascii_characters(){
});

await using var session = store.LightweightSession();


//The ngram uðmu should only exist in bjork, if special characters ignored it will return Umut
var umut = new User(1, "Umut Aral");
var bjork = new User(2, "Björk Guðmundsdóttir");
Expand Down
2 changes: 1 addition & 1 deletion src/Marten/Schema/DocumentSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public DocumentSchema(DocumentMapping mapping)
public IEnumerable<Type> DependentTypes()
{
yield return typeof(SystemFunctions);

yield return typeof(RequiredExtensions);
foreach (var referencedType in _mapping.ReferencedTypes()) yield return referencedType;
}

Expand Down
36 changes: 36 additions & 0 deletions src/Marten/Storage/RequiredExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.IO;
using Weasel.Core;
using Weasel.Core.Migrations;
using Weasel.Postgresql;

namespace Marten.Storage;

internal class RequiredExtensions: IFeatureSchema
{
private readonly StoreOptions _options;

public RequiredExtensions(StoreOptions options)
{
_options = options;
}

public ISchemaObject[] Objects => [new Extension("unaccent")];

public string Identifier => "requiredextensions";

public Migrator Migrator => _options.Advanced.Migrator;

public Type StorageType => typeof(RequiredExtensions);

public IEnumerable<Type> DependentTypes()
{
yield break;
}

public void WritePermissions(Migrator rules, TextWriter writer)
{
//Nothing
}
}
6 changes: 5 additions & 1 deletion src/Marten/Storage/StorageFeatures.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ internal StorageFeatures(StoreOptions options)
_options = options;

SystemFunctions = new SystemFunctions(options);
RequiredExtensions = new RequiredExtensions(options);
}

/// <summary>
Expand All @@ -50,6 +51,7 @@ internal StorageFeatures(StoreOptions options)
public List<ISchemaObject> ExtendedSchemaObjects { get; } = new();

internal SystemFunctions SystemFunctions { get; }
internal RequiredExtensions RequiredExtensions{get;}

internal IEnumerable<DocumentMapping> AllDocumentMappings =>
_documentMappings.Value.Enumerate().Select(x => x.Value);
Expand Down Expand Up @@ -262,6 +264,7 @@ public IFeatureSchema FindFeature(Type featureType)

internal void PostProcessConfiguration()
{
Add(RequiredExtensions);
SystemFunctions.AddSystemFunction(_options, "mt_immutable_timestamp", "text");
SystemFunctions.AddSystemFunction(_options, "mt_immutable_timestamptz", "text");
SystemFunctions.AddSystemFunction(_options, "mt_immutable_time", "text");
Expand All @@ -278,7 +281,7 @@ internal void PostProcessConfiguration()
SystemFunctions.AddSystemFunction(_options, "mt_jsonb_move", "jsonb,text[],text");
SystemFunctions.AddSystemFunction(_options, "mt_jsonb_path_to_array", "text,char(1)");
SystemFunctions.AddSystemFunction(_options, "mt_jsonb_remove", "jsonb,text[],jsonb");
SystemFunctions.AddSystemFunction(_options, "mt_jsonb_patch", "jsonb,jsonb");
SystemFunctions.AddSystemFunction(_options, "mt_jsonb_patch", "jsonb,jsonb");

Add(SystemFunctions);

Expand All @@ -303,6 +306,7 @@ internal void PostProcessConfiguration()

internal IEnumerable<IFeatureSchema> AllActiveFeatures(IMartenDatabase database)
{
yield return RequiredExtensions;
yield return SystemFunctions;

if (_options.Events.As<EventGraph>().IsActive(_options))
Expand Down