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

torand / FasterSQL / 16990059345

15 Aug 2025 12:34PM UTC coverage: 66.782% (-6.6%) from 73.399%
16990059345

push

github

torand
chore: access central snapshots

294 of 598 branches covered (49.16%)

Branch coverage included in aggregate %.

1638 of 2295 relevant lines covered (71.37%)

3.83 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
     */
40
    public AnsiIsoDialect() {}
×
41

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

145
    @Override
146
    public boolean supports(Capability capability) {
147
        return SUPPORTED_CAPS.contains(capability);
×
148
    }
149
}
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