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
5 changes: 5 additions & 0 deletions csharp/.changeset/support-string-id-aliases.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'Foundation.Data.Doublets.Cli': minor
---

Added full string ID alias support for advanced LiNo queries through the named types decorator.
Original file line number Diff line number Diff line change
Expand Up @@ -1501,14 +1501,37 @@ public void DeduplicateNamedLinks_MultipleQueries_ShouldReuseSameIds()
});
}

[Fact]
public void StringAliasesInVariableRestriction_ShouldConstrainMatchesToNamedLinks()
{
RunTestWithLinks(links =>
{
ProcessQuery(links, "(() ((father: father father)))");
ProcessQuery(links, "(() ((mother: mother mother)))");
ProcessQuery(links, "(() ((child: father mother)))");

var fatherId = links.GetByName("father");
var motherId = links.GetByName("mother");
var childId = links.GetByName("child");

ProcessQuery(links, "((($id: father mother)) (($id: mother father)))");

var allLinks = GetAllLinks(links);
Assert.Equal(3, allLinks.Count);
AssertLinkExists(allLinks, fatherId, fatherId, fatherId);
AssertLinkExists(allLinks, motherId, motherId, motherId);
AssertLinkExists(allLinks, childId, motherId, fatherId);
});
}

// Helper methods
private static void RunTestWithLinks(Action<NamedLinksDecorator<uint>> testAction, bool enableTracing = false)
private static void RunTestWithLinks(Action<NamedTypesDecorator<uint>> testAction, bool enableTracing = false)
{
string tempDbFile = Path.GetTempFileName();
NamedLinksDecorator<uint>? decoratedLinks = null;
NamedTypesDecorator<uint>? decoratedLinks = null;
try
{
decoratedLinks = new NamedLinksDecorator<uint>(tempDbFile, tracingEnabled: enableTracing);
decoratedLinks = new NamedTypesDecorator<uint>(tempDbFile, tracingEnabled: enableTracing);

using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(1));
var task = Task.Run(() =>
Expand Down Expand Up @@ -1536,7 +1559,7 @@ private static void RunTestWithLinks(Action<NamedLinksDecorator<uint>> testActio
}
}

private static List<DoubletLink> GetAllLinks(NamedLinksDecorator<uint> links)
private static List<DoubletLink> GetAllLinks(NamedTypesDecorator<uint> links)
{
var any = links.Constants.Any;
var query = new DoubletLink(index: any, source: any, target: any);
Expand All @@ -1545,23 +1568,23 @@ private static List<DoubletLink> GetAllLinks(NamedLinksDecorator<uint> links)
return allLinks;
}

private static void ProcessQuery(NamedLinksDecorator<uint> links, string query)
private static void ProcessQuery(NamedTypesDecorator<uint> links, string query)
{
ProcessQuery(links, new Options { Query = query });
}

private static void ProcessQuery(NamedLinksDecorator<uint> links, Options options)
private static void ProcessQuery(NamedTypesDecorator<uint> links, Options options)
{
options.AutoCreateMissingReferences = true;
Foundation.Data.Doublets.Cli.AdvancedMixedQueryProcessor.ProcessQuery(links, options);
}

private static void ProcessQueryStrict(NamedLinksDecorator<uint> links, string query)
private static void ProcessQueryStrict(NamedTypesDecorator<uint> links, string query)
{
ProcessQueryStrict(links, new Options { Query = query });
}

private static void ProcessQueryStrict(NamedLinksDecorator<uint> links, Options options)
private static void ProcessQueryStrict(NamedTypesDecorator<uint> links, Options options)
{
options.AutoCreateMissingReferences = false;
Foundation.Data.Doublets.Cli.AdvancedMixedQueryProcessor.ProcessQuery(links, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,14 @@ public void WriteToFile_WritesCompleteDatabaseAsLinoLines()
});
}

private static void WithNamedLinks(Action<NamedLinksDecorator<uint>> test)
private static void WithNamedLinks(Action<NamedTypesDecorator<uint>> test)
{
var dbPath = Path.GetTempFileName();
var namesDbPath = NamedLinksDecorator<uint>.MakeNamesDatabaseFilename(dbPath);
var namesDbPath = NamedTypesDecorator<uint>.MakeNamesDatabaseFilename(dbPath);

try
{
var links = new NamedLinksDecorator<uint>(dbPath, false);
var links = new NamedTypesDecorator<uint>(dbPath, false);
test(links);
}
finally
Expand Down
Loading
Loading