public override void Visit(SqlExtract node) { if (node.DateTimePart == SqlDateTimePart.DayOfWeek) { Visit((DatePartWeekDay(node.Operand) + DateFirst + 6) % 7); return; } switch (node.IntervalPart) { case SqlIntervalPart.Day: Visit(CastToLong(node.Operand / NanosecondsPerDay)); return; case SqlIntervalPart.Hour: Visit(CastToLong(node.Operand / (60 * 60 * NanosecondsPerSecond)) % 24); return; case SqlIntervalPart.Minute: Visit(CastToLong(node.Operand / (60 * NanosecondsPerSecond)) % 60); return; case SqlIntervalPart.Second: Visit(CastToLong(node.Operand / NanosecondsPerSecond) % 60); return; case SqlIntervalPart.Millisecond: Visit(CastToLong(node.Operand / NanosecondsPerMillisecond) % MillisecondsPerSecond); return; case SqlIntervalPart.Nanosecond: Visit(CastToLong(node.Operand)); return; } base.Visit(node); }
public void Visit(SqlExtract node) { if (!node.Operand.IsNullReference()) { Visit(node.Operand); } }
private void VisitDateTimeOffset(SqlExtract node) { switch (node.DateTimeOffsetPart) { case SqlDateTimeOffsetPart.Date: DateTimeTruncate(DateTimeOffsetExtractDateTimeAsString(node.Operand)).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.DateTime: DateTime(DateTimeOffsetExtractDateTimeAsString(node.Operand)).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.LocalDateTime: DateTimeOffsetToLocalDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.UtcDateTime: DateTimeOffsetToUtcDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Offset: (DateTimeOffsetExtractOffsetAsTotalNanoseconds(node.Operand)).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.TimeZoneHour: (DateTimeOffsetExtractOffsetAsTotalNanoseconds(node.Operand) / NanosecondsPerHour).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.TimeZoneMinute: (((DateTimeOffsetExtractOffsetAsTotalNanoseconds(node.Operand)) % NanosecondsPerHour) / (60 * NanosecondsPerSecond)).AcceptVisitor(this); return; } Visit(SqlDml.Extract(ConvertDateTimeOffsetPartToDateTimePart(node.DateTimeOffsetPart), DateTimeOffsetExtractDateTimeAsString(node.Operand))); }
public override string Translate(SqlCompilerContext context, SqlExtract node, ExtractSection section) { if (node.DateTimePart == SqlDateTimePart.Second || node.IntervalPart == SqlIntervalPart.Second) { switch (section) { case ExtractSection.Entry: return("TRUNC(EXTRACT("); case ExtractSection.Exit: return("))"); default: return(base.Translate(context, node, section)); } } if (node.DateTimePart == SqlDateTimePart.Millisecond || node.IntervalPart == SqlIntervalPart.Millisecond) { switch (section) { case ExtractSection.Entry: return("MOD(EXTRACT("); case ExtractSection.Exit: return(")*1000,1000)"); default: return(base.Translate(context, node, section)); } } return(base.Translate(context, node, section)); }
private void VisitInterval(SqlExtract node) { switch (node.IntervalPart) { case SqlIntervalPart.Day: Visit(CastToLong(node.Operand / NanosecondsPerDay)); return; case SqlIntervalPart.Hour: Visit(CastToLong(node.Operand / (60 * 60 * NanosecondsPerSecond)) % 24); return; case SqlIntervalPart.Minute: Visit(CastToLong(node.Operand / (60 * NanosecondsPerSecond)) % 60); return; case SqlIntervalPart.Second: Visit(CastToLong(node.Operand / NanosecondsPerSecond) % 60); return; case SqlIntervalPart.Millisecond: Visit(CastToLong(node.Operand / NanosecondsPerMillisecond) % MillisecondsPerSecond); return; case SqlIntervalPart.Nanosecond: Visit(CastToLong(node.Operand % NanosecondsPerMillisecond)); return; } }
public override void Visit(SqlExtract node) { switch (node.DateTimeOffsetPart) { case SqlDateTimeOffsetPart.Date: DateTimeOffsetExtractDate(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.DateTime: DateTimeOffsetExtractDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.UtcDateTime: DateTimeOffsetToUtcDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.LocalDateTime: DateTimeOffsetToLocalDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Offset: DateTimeOffsetExtractOffset(node); return; } base.Visit(node); }
public override string Translate(SqlCompilerContext context, SqlExtract node, ExtractSection section) { var isSecond = node.DateTimePart == SqlDateTimePart.Second || node.IntervalPart == SqlIntervalPart.Second || node.DateTimeOffsetPart == SqlDateTimeOffsetPart.Second; var isMillisecond = node.DateTimePart == SqlDateTimePart.Millisecond || node.IntervalPart == SqlIntervalPart.Millisecond || node.DateTimeOffsetPart == SqlDateTimeOffsetPart.Millisecond; if (!(isSecond || isMillisecond)) { return(base.Translate(context, node, section)); } switch (section) { case ExtractSection.Entry: return(isSecond ? "(trunc(extract(" : "(extract("); case ExtractSection.Exit: return(isMillisecond ? ")::int8 % 1000)" : isSecond ? ")))" : ")::int8)"); default: return(base.Translate(context, node, section)); } }
/// <inheritdoc/> public override void Visit(SqlExtract node) { switch (node.IntervalPart) { case SqlIntervalPart.Day: Visit(CastToLong(node.Operand / NanosecondsPerDay)); return; case SqlIntervalPart.Hour: Visit(CastToLong(node.Operand / (60 * 60 * NanosecondsPerSecond)) % 24); return; case SqlIntervalPart.Minute: Visit(CastToLong(node.Operand / (60 * NanosecondsPerSecond)) % 60); return; case SqlIntervalPart.Second: Visit(CastToLong(node.Operand / NanosecondsPerSecond) % 60); return; case SqlIntervalPart.Millisecond: Visit(CastToLong(node.Operand / NanosecondsPerMillisecond) % MillisecondsPerSecond); return; case SqlIntervalPart.Nanosecond: Visit(CastToLong(node.Operand)); return; } switch (node.DateTimePart) { case SqlDateTimePart.DayOfYear: if (!case_SqlDateTimePart_DayOfYear) { case_SqlDateTimePart_DayOfYear = true; Visit(SqlDml.Add(node, SqlDml.Literal(1))); case_SqlDateTimePart_DayOfYear = false; } else { base.Visit(node); } return; case SqlDateTimePart.Second: if (!case_SqlDateTimePart_Second) { case_SqlDateTimePart_Second = true; Visit(SqlDml.Truncate(node)); case_SqlDateTimePart_Second = false; } else { base.Visit(node); } return; } base.Visit(node); }
private void VisitDateTime(SqlExtract node) { if (node.DateTimePart == SqlDateTimePart.Millisecond) { Visit(CastToLong(DateGetMilliseconds(node.Operand))); return; } base.Visit(node); }
public override void Visit(SqlExtract node) { if (node.DateTimePart == SqlDateTimePart.DayOfWeek || node.DateTimePart == SqlDateTimePart.DayOfYear) { Visit(SqlDml.FunctionCall(node.DateTimePart.ToString(), node.Operand)); return; } base.Visit(node); }
public override string Translate(SqlCompilerContext context, SqlExtract node, ExtractSection section) { switch (section) { case ExtractSection.Entry: return("DATEPART("); case ExtractSection.From: return(","); default: return(base.Translate(context, node, section)); } }
/// <inheritdoc/> public override string Translate(SqlCompilerContext context, SqlExtract extract, ExtractSection section) { switch (section) { case ExtractSection.Entry: return("CAST(STRFTIME("); case ExtractSection.From: return(", "); case ExtractSection.Exit: return(") as INTEGER)"); default: return(string.Empty); } }
protected void DateTimeOffsetExtractOffset(SqlExtract node) { using (context.EnterScope(node)) { context.Output.AppendText(translator.Translate(context, node, ExtractSection.Entry)); var part = node.DateTimePart != SqlDateTimePart.Nothing ? translator.Translate(node.DateTimePart) : node.IntervalPart != SqlIntervalPart.Nothing ? translator.Translate(node.IntervalPart) : translator.Translate(node.DateTimeOffsetPart); context.Output.AppendText(part); context.Output.AppendText(translator.Translate(context, node, ExtractSection.From)); node.Operand.AcceptVisitor(this); context.Output.AppendText(translator.Translate(context, node, ExtractSection.Exit)); context.Output.AppendText(translator.Translate(SqlNodeType.Multiply)); OneSecondInterval.AcceptVisitor(this); } }
public override void Visit(SqlExtract node) { if (node.IntervalPart != SqlIntervalPart.Nothing) { VisitInterval(node); return; } if (node.DateTimePart != SqlDateTimePart.Nothing) { VisitDateTime(node); return; } if (node.DateTimeOffsetPart != SqlDateTimeOffsetPart.Nothing) { VisitDateTimeOffset(node); return; } base.Visit(node); }
public override void Visit(SqlExtract node) { if (node.DateTimeOffsetPart == SqlDateTimeOffsetPart.DayOfWeek) { Visit((DatePartWeekDay(node.Operand) + DateFirst + 6) % 7); return; } switch (node.DateTimeOffsetPart) { case SqlDateTimeOffsetPart.TimeZoneHour: Visit(DateTimeOffsetTimeZoneInMinutes(node.Operand) / 60); return; case SqlDateTimeOffsetPart.TimeZoneMinute: Visit(DateTimeOffsetTimeZoneInMinutes(node.Operand) % 60); return; case SqlDateTimeOffsetPart.Date: DateTimeOffsetTruncate(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.DateTime: DateTimeOffsetTruncateOffset(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.LocalDateTime: DateTimeOffsetToLocalDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.UtcDateTime: SqlDml.Cast(Switchoffset(node.Operand, "+00:00"), SqlType.DateTime).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Offset: DateTimeOffsetPartOffset(node.Operand).AcceptVisitor(this); return; } base.Visit(node); }
public override string Translate(SqlCompilerContext context, SqlExtract node, ExtractSection section) { switch (node.IntervalPart) { case SqlIntervalPart.Day: case SqlIntervalPart.Hour: break; default: return(base.Translate(context, node, section)); } switch (section) { case ExtractSection.From: return("from justify_hours("); case ExtractSection.Exit: return("))"); default: return(base.Translate(context, node, section)); } }
public override void Visit(SqlExtract node) { switch (node.DateTimeOffsetPart) { case SqlDateTimeOffsetPart.Day: DateTimeOffsetExtractPart(node.Operand, "DD").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Hour: DateTimeOffsetExtractPart(node.Operand, "HH24").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Millisecond: DateTimeOffsetExtractPart(node.Operand, "FF3").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Nanosecond: DateTimeOffsetExtractPart(node.Operand, "FF9").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Minute: DateTimeOffsetExtractPart(node.Operand, "MI").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Month: DateTimeOffsetExtractPart(node.Operand, "MM").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Second: DateTimeOffsetExtractPart(node.Operand, "SS").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Year: DateTimeOffsetExtractPart(node.Operand, "YYYY").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.TimeZoneHour: DateTimeOffsetExtractPart(node.Operand, "TZH").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.TimeZoneMinute: DateTimeOffsetExtractPart(node.Operand, "TZM").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.DayOfWeek: DateTimeExtractDayOfWeek(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.DayOfYear: DateTimeOffsetExtractPart(node.Operand, "DDD").AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Date: DateTimeOffsetTruncate(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.DateTime: DateTimeOffsetTruncateOffset(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.LocalDateTime: DateTimeOffsetToLocalDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.UtcDateTime: DateTimeOffsetToUtcDateTime(node.Operand).AcceptVisitor(this); return; case SqlDateTimeOffsetPart.Offset: DateTimeOffsetPartOffset(node.Operand).AcceptVisitor(this); return; } switch (node.DateTimePart) { case SqlDateTimePart.DayOfYear: DateTimeExtractDayOfYear(node.Operand).AcceptVisitor(this); return; case SqlDateTimePart.DayOfWeek: DateTimeExtractDayOfWeek(node.Operand).AcceptVisitor(this); return; default: base.Visit(node); return; } }
public virtual void Visit(SqlExtract node) { VisitInternal(node.Operand); }