• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

torand / FasterSQL / 17012572989

16 Aug 2025 08:26PM UTC coverage: 68.265% (-0.008%) from 68.273%
17012572989

push

github

torand
refactor: sonar cloud issues

299 of 598 branches covered (50.0%)

Branch coverage included in aggregate %.

33 of 47 new or added lines in 18 files covered. (70.21%)

1 existing line in 1 file now uncovered.

1680 of 2301 relevant lines covered (73.01%)

3.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/main/java/io/github/torand/fastersql/dialect/AnsiIsoDialect.java
1
/*
2
 * Copyright (c) 2024-2025 Tore Eide Andersen
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *      http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package io.github.torand.fastersql.dialect;
17

18
import io.github.torand.fastersql.function.singlerow.cast.DataType;
19

20
import java.util.EnumSet;
21
import java.util.List;
22
import java.util.Optional;
23

24
import static io.github.torand.fastersql.dialect.Capability.FULL_OUTER_JOIN;
25
import static io.github.torand.fastersql.dialect.Capability.LIMIT_OFFSET;
26
import static io.github.torand.fastersql.dialect.Capability.MODULO_OPERATOR;
27
import static io.github.torand.fastersql.dialect.Capability.SELECT_FOR_UPDATE;
28
import static io.github.torand.fastersql.dialect.Capability.SET_OPERATION_PARENTHESES;
29
import static io.github.torand.fastersql.dialect.Capability.TRUNCATE_TABLE;
30

31
/**
32
 * Defines the <a href="https://standards.iso.org/iso-iec/9075/-2/ed-6/en/ISO_IEC_9075-2(E)_Foundation.bnf.txt">ANSI/ISO</a> (ISO/IEC 9075) SQL dialect.
33
 */
34
public class AnsiIsoDialect implements Dialect {
35
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, MODULO_OPERATOR, SELECT_FOR_UPDATE, TRUNCATE_TABLE, FULL_OUTER_JOIN, SET_OPERATION_PARENTHESES);
×
36

37
    /**
38
     * Creates an ANSI/ISO {@link Dialect} implementation.
39
     */
NEW
40
    public AnsiIsoDialect() {
×
41
        // Default constructor required by Javadoc
NEW
42
    }
×
43

44
    @Override
45
    public String getProductName() {
46
        return "ANSI/ISO";
×
47
    }
48

49
    @Override
50
    public boolean offsetBeforeLimit() {
51
        return true;
×
52
    }
53

54
    @Override
55
    public Optional<String> formatRowOffsetClause() {
56
        return Optional.of("offset ? rows");
×
57
    }
58

59
    @Override
60
    public Optional<String> formatRowLimitClause() {
61
        return Optional.of("fetch next ? rows only");
×
62
    }
63

64
    @Override
65
    public Optional<String> formatRowNumLiteral() {
66
        return Optional.empty();
×
67
    }
68

69
    @Override
70
    public String formatToNumberFunction(String operand, int precision, int scale) {
71
        return "to_number(%s)".formatted(operand);
×
72
    }
73

74
    @Override
75
    public String formatToCharFunction(String operand, String format) {
76
        return "to_char(%s, %s)".formatted(operand, format);
×
77
    }
78

79
    @Override
80
    public String formatSubstringFunction(String operand, int startPos, int length) {
81
        return "substring(" + operand + ", " + startPos + ", " + length + ")";
×
82
    }
83

84
    @Override
85
    public String formatConcatFunction(List<String> operands) {
86
        return "concat(%s)".formatted(String.join(", ", operands));
×
87
    }
88

89
    @Override
90
    public String formatLengthFunction(String operand) {
91
        return "length(" + operand + ")";
×
92
    }
93

94
    @Override
95
    public String formatCeilFunction(String operand) {
96
        return "ceil(" + operand + ")";
×
97
    }
98

99
    @Override
100
    public String formatLnFunction(String operand) {
101
        return "ln(" + operand + ")";
×
102
    }
103

104
    @Override
105
    public String formatRoundFunction(String operand) {
106
        return "round(" + operand + ")";
×
107
    }
108

109
    @Override
110
    public String formatModuloFunction(String divisor, String dividend) {
111
        throw new UnsupportedOperationException("ANSI/ISO SQL does not support the mod() function (use the modulo infix operator instead)");
×
112
    }
113

114
    @Override
115
    public String formatCurrentDateFunction() {
116
        return "current_date";
×
117
    }
118

119
    @Override
120
    public Optional<String> getDataType(DataType dataType) {
121
        return Optional.ofNullable(switch(dataType.getIsoDataType()) {
×
122
            case BOOLEAN -> "boolean";
×
123
            case CHAR -> "char";
×
124
            case VARCHAR -> "varchar";
×
125
            case BIT -> "bit";
×
126
            case BIT_VARYING -> "bit varying";
×
127
            case NUMERIC -> "numeric";
×
128
            case DECIMAL -> "decimal";
×
129
            case INTEGER -> "integer";
×
130
            case SMALLINT -> "smallint";
×
131
            case FLOAT -> "float";
×
132
            case DOUBLE_PRECISION -> "double precision";
×
133
            case REAL -> "real";
×
134
            case TIME -> "time";
×
135
            case DATE -> "date";
×
136
            case INTERVAL -> "interval";
×
137
            case CHARACTER_LARGE_OBJECT -> "clob";
×
138
            case BINARY_LARGE_OBJECT -> "blob";
×
139
        });
140
    }
141

142
    @Override
143
    public Optional<String> getConcatOperator() {
144
        return Optional.of("||");
×
145
    }
146

147
    @Override
148
    public boolean supports(Capability capability) {
149
        return SUPPORTED_CAPS.contains(capability);
×
150
    }
151
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc