Class YdbSqlExpressionConvertVisitor
- Namespace
- LinqToDB.Internal.DataProvider.Ydb
- Assembly
- linq2db.dll
public class YdbSqlExpressionConvertVisitor : SqlExpressionConvertVisitor
- Inheritance
-
objectYdbSqlExpressionConvertVisitor
- Inherited Members
- Extension Methods
Constructors
YdbSqlExpressionConvertVisitor(bool)
public YdbSqlExpressionConvertVisitor(bool allowModify)
Parameters
allowModifybool
Fields
YdbLikeCharactersToEscape
protected static string[] YdbLikeCharactersToEscape
Field Value
- string[]
Properties
CanLowerIntervalDifference
Whether an elapsed date difference can be lowered to a value here.
public override bool CanLowerIntervalDifference { get; }
Property Value
Remarks
Declared beside the lowering it describes, and read by the member translator through
ITranslationContext.ProviderFlags. The translator has to ask before it builds anything, because
a difference it does not build stays an ordinary .NET subtraction and is computed on materialisation -
and by the time this visitor runs, the read expression is already bound to its columns, so there is no
going back.
CanLowerIntervalShift
Whether LowerTemporalArithmetic(SqlTemporalArithmeticExpression) can express a date shifted by an interval at all.
public override bool CanLowerIntervalShift { get; }
Property Value
Remarks
Read by the member translator so a declared duration added to a date is declined while the expression is still being built, rather than reaching the builder as a node nothing can render - a refusal there has no client-side fallback left. The default follows what the base implementation needs: it spends the amount through ShiftDate(SqlIntervalUnit, ISqlExpression, ISqlExpression) at FinestDateUnit, so a provider that names no finest unit cannot lower one.
Only the declared half is declined early. A shift by a computed difference is left to be built,
because start + (end - start) cancels against the difference it came from and asks the provider
for nothing - refusing it here would sink a query that works everywhere.
ConcatRequiresExplicitStringCast
When true (default), ConvertConcat(SqlConcatExpression) wraps every non-string
operand in an explicit CAST(... AS VARCHAR(N)) before adding it to the concat chain.
Required for providers whose concat operator is + (SQL Server pre-2025, SqlCe,
Access) — SQL-standard data-type precedence would otherwise try to coerce
string operands to the non-string side's type. Most providers whose final concat operator
is || (PostgreSQL / Oracle / SQLite / SAP HANA / DuckDB / Firebird / DB2 / Informix /
SQL Server 2025+) or CONCAT(...) function (MySQL / ClickHouse) auto-coerce
non-string operands and override this to false for cleaner SQL.
Sybase ASE is the exception: it emits || but keeps this true,
since ASE requires an explicit convert() for non-character operands under both
+ and ||.
protected override bool ConcatRequiresExplicitStringCast { get; }
Property Value
LikeCharactersToEscape
Characters with special meaning in LIKE predicate (defined by LikeCharactersToEscape) that should be escaped to be used as matched character.
Default: ["%", "_", "?", "*", "#", "[", "]"].
public override string[] LikeCharactersToEscape { get; }
Property Value
- string[]
SupportsNullIf
protected override bool SupportsNullIf { get; }
Property Value
SupportsNullInColumn
protected override bool SupportsNullInColumn { get; }
Property Value
Methods
ConvertConversion(SqlCastExpression)
Implements SqlCastExpression conversion.
protected override ISqlExpression ConvertConversion(SqlCastExpression cast)
Parameters
castSqlCastExpression
Returns
ConvertDefaultValue(SqlDefaultValueExpression)
Writes the default a reader substitutes for a NULL: as its value here, and as the least value of the column's type where a provider's type cannot hold it.
public override ISqlExpression ConvertDefaultValue(SqlDefaultValueExpression expression)
Parameters
expressionSqlDefaultValueExpressionThe default to write.
Returns
- ISqlExpression
The expression the default is written as.
ConvertSearchStringPredicate(SearchString)
public override ISqlPredicate ConvertSearchStringPredicate(SqlPredicate.SearchString predicate)
Parameters
predicateSqlPredicate.SearchString
Returns
ConvertSqlBinaryExpression(SqlBinaryExpression)
public override IQueryElement ConvertSqlBinaryExpression(SqlBinaryExpression element)
Parameters
elementSqlBinaryExpression
Returns
ConvertSqlCaseExpression(SqlCaseExpression)
protected override ISqlExpression ConvertSqlCaseExpression(SqlCaseExpression element)
Parameters
elementSqlCaseExpression
Returns
ConvertSqlFunction(SqlFunction)
public override ISqlExpression ConvertSqlFunction(SqlFunction func)
Parameters
funcSqlFunction
Returns
ConvertSqlUnaryExpression(SqlUnaryExpression)
public override ISqlExpression ConvertSqlUnaryExpression(SqlUnaryExpression element)
Parameters
elementSqlUnaryExpression
Returns
CreateLikeEscapeCharacter()
public override ISqlExpression CreateLikeEscapeCharacter()
Returns
ElapsedTicks(SqlIntervalDifferenceExpression)
Elapsed ticks from the microsecond count a YQL Interval casts to.
protected override ISqlExpression? ElapsedTicks(SqlIntervalDifferenceExpression element)
Parameters
elementSqlIntervalDifferenceExpression
Returns
Remarks
Subtracting two temporal values yields an Interval, and casting one to Int64 gives the
microseconds it holds - which is also the finest a YDB timestamp stores, so scaling to ticks loses
nothing. The subtraction has to carry the interval type, or the cast reads as a no-op between two
Int64 values and is pruned.
LowerTemporalArithmetic(SqlTemporalArithmeticExpression)
Shifts by building a YQL Interval from the tick count (microsecond resolution - YDB's own) and
adding it natively.
protected override ISqlExpression? LowerTemporalArithmetic(SqlTemporalArithmeticExpression element)
Parameters
elementSqlTemporalArithmeticExpression
Returns
Remarks
A DateTime is cast to Timestamp first, whatever its mapping declares: adding an
interval keeps the type of the date, and a Date or a Datetime hold no time of day and no
fraction of a second respectively, while a column of either mapped as a plain DateTime is not
declared as one. The target is built from the CLR type, so a mapped DbType does not render the cast
as the type it was meant to leave. The wide types go to Timestamp64 instead: a Timestamp would
not hold their range, while a Date32 or a Datetime64 would drop the time as the narrow ones do.
The sum is optional in YQL, even over two values that cannot be absent, and an optional cannot be written to a column that is not nullable. So it is cast to its own type, which the builder unwraps wherever the value cannot be null.
VisitInSubQueryPredicate(InSubQuery)
protected override IQueryElement VisitInSubQueryPredicate(SqlPredicate.InSubQuery predicate)
Parameters
predicateSqlPredicate.InSubQuery