Class DB2SqlExpressionConvertVisitor
- Namespace
- LinqToDB.Internal.DataProvider.DB2
- Assembly
- linq2db.dll
public class DB2SqlExpressionConvertVisitor : SqlExpressionConvertVisitor
- Inheritance
-
objectDB2SqlExpressionConvertVisitor
- Inherited Members
- Extension Methods
Constructors
DB2SqlExpressionConvertVisitor(bool)
public DB2SqlExpressionConvertVisitor(bool allowModify)
Parameters
allowModifybool
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.
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
IntervalResolution
The tick count is built from MICROSECOND() scaled by ten, so it is a multiple of ten by
construction and a component below the microsecond is identically zero rather than merely imprecise.
public override SqlIntervalUnit IntervalResolution { get; }
Property Value
Remarks
Declared even though a column may be wider - timestamp(7) is what this fixture's model asks for -
because what the measurement can distinguish is what the count is taken from, not what the column holds.
The declined member falls back to .NET and answers from the two dates.
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
ConvertSqlBinaryExpression(SqlBinaryExpression)
public override IQueryElement ConvertSqlBinaryExpression(SqlBinaryExpression element)
Parameters
elementSqlBinaryExpression
Returns
ConvertSqlFunction(SqlFunction)
public override ISqlExpression ConvertSqlFunction(SqlFunction func)
Parameters
funcSqlFunction
Returns
ConvertSqlUnaryExpression(SqlUnaryExpression)
public override ISqlExpression ConvertSqlUnaryExpression(SqlUnaryExpression element)
Parameters
elementSqlUnaryExpression
Returns
ElapsedTicks(SqlIntervalDifferenceExpression)
Elapsed ticks summed from the three fields a DB2 timestamp decomposes into.
protected override ISqlExpression? ElapsedTicks(SqlIntervalDifferenceExpression element)
Parameters
elementSqlIntervalDifferenceExpression
Returns
Remarks
TIMESTAMPDIFF is documented as an estimate - it assumes months of thirty days - so it cannot
answer this. A timestamp is a whole number of days plus seconds since midnight plus microseconds, and
each field's difference is exact, so their sum is the exact elapsed time. This is the same
decomposition the provider's DateDiff lowering already uses.
IsWindowOrderByRequired(SqlExtendedFunction)
Every ranking function, NTILE, and LAG/LEAD - all of them SQL0104N ... Expected
tokens may include: "ORDER BY" - plus any frame, which is SQL20117N A window specification for an
OLAP function is not valid on its own. ROW_NUMBER and the *_VALUE pair are fine
unordered, and so is an unframed aggregate.
protected override bool IsWindowOrderByRequired(SqlExtendedFunction func)
Parameters
funcSqlExtendedFunction
Returns
WrapColumnExpression(ISqlExpression)
protected override ISqlExpression WrapColumnExpression(ISqlExpression expr)
Parameters
exprISqlExpression