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));
            }
        }
Exemple #2
0
        /// <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);
            }
        }
        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 node, ExtractSection section)
        {
            bool isSecond      = node.DateTimePart == SqlDateTimePart.Second || node.IntervalPart == SqlIntervalPart.Second;
            bool isMillisecond = node.DateTimePart == SqlDateTimePart.Millisecond ||
                                 node.IntervalPart == SqlIntervalPart.Millisecond;

            if (!(isSecond || isMillisecond))
            {
                return(base.Translate(context, node, section));
            }
            switch (section)
            {
            case ExtractSection.Entry:
                return("(extract(");

            case ExtractSection.Exit:
                return(isMillisecond ? ") % 1000)" : "))");

            default:
                return(base.Translate(context, node, section));
            }
        }
        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));
        }
        public override string Translate(SqlCompilerContext context, SqlExtract node, ExtractSection section)
        {
            bool isSecond = node.DateTimePart == SqlDateTimePart.Second ||
                            node.IntervalPart == SqlIntervalPart.Second
                            /*|| node.DateTimeOffsetPart==SqlDateTimeOffsetPart.Second*/;
            bool 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:
                if (isSecond)
                {
                    return("(trunc(extract(");
                }
                return("(extract(");

            case ExtractSection.Exit:
                if (isMillisecond)
                {
                    return(")::int8 % 1000)");
                }
                if (isSecond)
                {
                    return(")))");
                }
                return(")::int8)");

            //return isMillisecond ? ")::int8 % 1000)" : ")::int8)";
            default:
                return(base.Translate(context, node, section));
            }
        }