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

torand / FasterSQL / 13389227868

18 Feb 2025 11:10AM UTC coverage: 59.667% (+0.9%) from 58.785%
13389227868

push

github

torand
test: H2 specific testing of select and insert clauses

157 of 346 branches covered (45.38%)

Branch coverage included in aggregate %.

846 of 1335 relevant lines covered (63.37%)

3.35 hits per line

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

59.26
/src/main/java/io/github/torand/fastersql/dialect/OracleDialect.java
1
/*
2
 * Copyright (c) 2024 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 java.util.EnumSet;
19
import java.util.List;
20
import java.util.Optional;
21

22
import static io.github.torand.fastersql.dialect.Capability.CONCAT_OPERATOR;
23
import static io.github.torand.fastersql.dialect.Capability.LIMIT_OFFSET;
24
import static io.github.torand.fastersql.util.lang.StringHelper.generate;
25

26
public class OracleDialect implements Dialect {
27
    private final EnumSet<Capability> supportedCaps;
28

29
    public OracleDialect() {
30
        this(EnumSet.of(LIMIT_OFFSET, CONCAT_OPERATOR));
5✔
31
    }
1✔
32

33
    private OracleDialect(EnumSet<Capability> capabilities) {
2✔
34
        this.supportedCaps = EnumSet.copyOf(capabilities);
4✔
35
    }
1✔
36

37
    @Override
38
    public String getProductName() {
39
        return "Oracle";
2✔
40
    }
41

42
    @Override
43
    public boolean offsetBeforeLimit() {
44
        return true;
2✔
45
    }
46

47
    /**
48
     * Row offset clause is supported from Oracle 12c onwards
49
     */
50
    @Override
51
    public Optional<String> formatRowOffsetClause() {
52
        return Optional.of("offset ? rows");
3✔
53
    }
54

55
    /**
56
     * Row limit clause is supported from Oracle 12c onwards
57
     */
58
    @Override
59
    public Optional<String> formatRowLimitClause() {
60
        return Optional.of("fetch next ? rows only");
3✔
61
    }
62

63
    @Override
64
    public Optional<String> formatRowNumLiteral() {
65
        return Optional.of("rownum");
3✔
66
    }
67

68
    @Override
69
    public String formatToNumberFunction(String operand, int precision, int scale) {
70
        StringBuilder mask = new StringBuilder();
×
71
        if (precision-scale > 0) {
×
72
            mask.append(generate("9", precision-scale));
×
73
        }
74
        if (scale > 0) {
×
75
            mask.append(".").append(generate("9", scale));
×
76
        }
77

78
        return "to_number(" + operand + ", '" + mask + "')";
×
79
    }
80

81
    @Override
82
    public String formatSubstringFunction(String operand, int startPos, int length) {
83
        return "substr(" + operand + ", " + startPos + ", " + length + ")";
5✔
84
    }
85

86
    @Override
87
    public String formatConcatFunction(List<String> operands) {
88
        throw new UnsupportedOperationException("Use the concat infix operator for Oracle");
×
89
    }
90

91
    @Override
92
    public String formatLengthFunction(String operand) {
93
        return "length(" + operand + ")";
3✔
94
    }
95

96
    @Override
97
    public boolean supports(Capability capability) {
98
        return supportedCaps.contains(capability);
5✔
99
    }
100

101
    /**
102
     * Row offset and limit clauses are supported from Oracle 12c onwards.
103
     * Invoke this method when using previous versions of Oracle, to simulate these clauses with subqueries.
104
     */
105
    public OracleDialect withLegacyRowLimiting() {
106
        EnumSet<Capability> reducedCaps = EnumSet.copyOf(supportedCaps);
4✔
107
        reducedCaps.remove(LIMIT_OFFSET);
4✔
108
        return new OracleDialect(reducedCaps);
5✔
109
    }
110
}
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