You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
52 lines
1.3 KiB
52 lines
1.3 KiB
using Connected.Expressions;
|
|
using Connected.Expressions.Languages;
|
|
using Connected.Expressions.Translation;
|
|
using Connected.Expressions.TypeSystem;
|
|
|
|
namespace Connected.ServiceModel.Client.Data;
|
|
internal sealed class CqlLanguage : QueryLanguage
|
|
{
|
|
private static CqlLanguage? _default;
|
|
|
|
static CqlLanguage()
|
|
{
|
|
SplitChars = new char[] { '.' };
|
|
}
|
|
|
|
public CqlLanguage()
|
|
{
|
|
TypeSystem = new CqlTypeSystem();
|
|
}
|
|
|
|
public override QueryTypeSystem TypeSystem { get; }
|
|
private static char[] SplitChars { get; }
|
|
public override bool AllowsMultipleCommands => true;
|
|
public override bool AllowSubqueryInSelectWithoutFrom => true;
|
|
public override bool AllowDistinctInAggregates => true;
|
|
|
|
public static CqlLanguage Default
|
|
{
|
|
get
|
|
{
|
|
if (_default is null)
|
|
Interlocked.CompareExchange(ref _default, new CqlLanguage(), null);
|
|
|
|
return _default;
|
|
}
|
|
}
|
|
|
|
public override string Quote(string name)
|
|
{
|
|
if (name.StartsWith("[") && name.EndsWith("]"))
|
|
return name;
|
|
else if (name.Contains('.'))
|
|
return $"[{string.Join("].[", name.Split(SplitChars, StringSplitOptions.RemoveEmptyEntries))}]";
|
|
else
|
|
return $"[{name}]";
|
|
}
|
|
|
|
public override Linguist CreateLinguist(ExpressionCompilationContext context, Translator translator)
|
|
{
|
|
return new CqlLinguist(context, this, translator);
|
|
}
|
|
} |