Skip to content

Commit f7083d9

Browse files
author
MPCoreDeveloper
committed
cli runner fix attempt 2
1 parent 54a2357 commit f7083d9

File tree

3 files changed

+42
-6
lines changed

3 files changed

+42
-6
lines changed

src/SharpCoreDB.Graph/HybridGraphVectorOptimizer.cs

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
namespace SharpCoreDB.Graph;
66

77
using SharpCoreDB.Services;
8+
using System.Linq;
89

910
/// <summary>
1011
/// Hybrid Graph-Vector Query Optimizer.
@@ -66,23 +67,52 @@ private static bool DetectGraphTraversal(ExpressionNode expression)
6667
return expression switch
6768
{
6869
GraphTraverseNode => true,
69-
InExpressionNode inExpr when inExpr.Expression is GraphTraverseNode => true,
70+
InExpressionNode inExpr => DetectGraphTraversalInExpression(inExpr),
7071
BinaryExpressionNode binary =>
7172
DetectGraphTraversal(binary.Left) || DetectGraphTraversal(binary.Right),
7273
_ => false
7374
};
7475
}
7576

77+
private static bool DetectGraphTraversalInExpression(InExpressionNode inExpr)
78+
{
79+
if (inExpr.Expression is not null && DetectGraphTraversal(inExpr.Expression))
80+
return true;
81+
82+
if (inExpr.Values.Count > 0 && inExpr.Values.Any(DetectGraphTraversal))
83+
return true;
84+
85+
if (inExpr.Subquery?.Where?.Condition is null)
86+
return false;
87+
88+
return DetectGraphTraversal(inExpr.Subquery.Where.Condition);
89+
}
90+
7691
private static bool DetectVectorSearch(ExpressionNode expression)
7792
{
7893
return expression switch
7994
{
8095
FunctionCallNode func when func.FunctionName.StartsWith("VEC_", StringComparison.OrdinalIgnoreCase) => true,
96+
InExpressionNode inExpr => DetectVectorSearchInExpression(inExpr),
8197
BinaryExpressionNode binary =>
8298
DetectVectorSearch(binary.Left) || DetectVectorSearch(binary.Right),
8399
_ => false
84100
};
85101
}
102+
103+
private static bool DetectVectorSearchInExpression(InExpressionNode inExpr)
104+
{
105+
if (inExpr.Expression is not null && DetectVectorSearch(inExpr.Expression))
106+
return true;
107+
108+
if (inExpr.Values.Count > 0 && inExpr.Values.Any(DetectVectorSearch))
109+
return true;
110+
111+
if (inExpr.Subquery?.Where?.Condition is null)
112+
return false;
113+
114+
return DetectVectorSearch(inExpr.Subquery.Where.Condition);
115+
}
86116
}
87117

88118
/// <summary>

src/SharpCoreDB/CultureInfoCollation.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,15 @@ public static bool IsValidLocale(string? localeName)
245245
if (string.IsNullOrWhiteSpace(localeName))
246246
return false;
247247

248+
var normalized = NormalizeLocaleName(localeName);
249+
if (!IsValidLocaleFormat(normalized))
250+
return false;
251+
248252
try
249253
{
250-
var normalized = NormalizeLocaleName(localeName);
251-
_ = CultureInfo.GetCultureInfo(normalized);
252-
return true;
254+
var culture = CultureInfo.GetCultureInfo(normalized);
255+
var isoCode = culture.TwoLetterISOLanguageName;
256+
return isoCode != "iv" && isoCode != "xx" && isoCode != "zz";
253257
}
254258
catch (CultureNotFoundException)
255259
{

tests/SharpCoreDB.Tests/Graph/HybridGraphVectorQueryTests.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,8 @@ private static SelectNode CreateSampleSelectWithGraphAndVector()
8585
var inExpr = new InExpressionNode
8686
{
8787
Expression = new ColumnReferenceNode { ColumnName = "id" },
88-
IsNot = false
88+
IsNot = false,
89+
Values = [graphTraverse]
8990
};
9091

9192
var whereCondition = new BinaryExpressionNode
@@ -120,7 +121,8 @@ private static SelectNode CreateSampleSelectWithGraphOnly()
120121

121122
var inExpr = new InExpressionNode
122123
{
123-
Expression = new ColumnReferenceNode { ColumnName = "id" }
124+
Expression = new ColumnReferenceNode { ColumnName = "id" },
125+
Values = [graphTraverse]
124126
};
125127

126128
return new SelectNode

0 commit comments

Comments
 (0)