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

torand / FasterSQL / 15346133148

30 May 2025 11:50AM UTC coverage: 70.397% (+0.1%) from 70.298%
15346133148

push

github

torand
chore: test javadoc publish

235 of 420 branches covered (55.95%)

Branch coverage included in aggregate %.

1237 of 1671 relevant lines covered (74.03%)

3.9 hits per line

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

88.89
/src/main/java/io/github/torand/fastersql/dialect/HsqldbDialect.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 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.CURRENT_TIME;
24
import static io.github.torand.fastersql.dialect.Capability.LIMIT_OFFSET;
25
import static io.github.torand.fastersql.dialect.Capability.NULL_ORDERING;
26
import static io.github.torand.fastersql.dialect.Capability.SELECT_FOR_UPDATE;
27
import static io.github.torand.fastersql.dialect.Capability.TRUNCATE_TABLE;
28

29
/**
30
 * Defines the <a href="https://hsqldb.org/doc/2.0/guide/sqlgeneral-chapt.html">HyperSQL</a> (HSQLDB) SQL dialect.
31
 */
32
public class HsqldbDialect implements Dialect {
33
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, CONCAT_OPERATOR, CURRENT_TIME, NULL_ORDERING, SELECT_FOR_UPDATE, TRUNCATE_TABLE);
26✔
34

35
    /**
36
     * Creates a HyperSQL (HSQLDB) {@link Dialect} implementation.
37
     */
38
    public HsqldbDialect() {}
3✔
39

40
    @Override
41
    public String getProductName() {
42
        return "HyperSQL/HSQLDB";
2✔
43
    }
44

45
    @Override
46
    public boolean offsetBeforeLimit() {
47
        return false;
2✔
48
    }
49

50
    @Override
51
    public Optional<String> formatRowOffsetClause() {
52
        return Optional.of("offset ?");
3✔
53
    }
54

55
    @Override
56
    public Optional<String> formatRowLimitClause() {
57
        return Optional.of("limit ?");
3✔
58
    }
59

60
    @Override
61
    public Optional<String> formatRowNumLiteral() {
62
        return Optional.of("rownum()");
×
63
    }
64

65
    @Override
66
    public String formatToNumberFunction(String operand, int precision, int scale) {
67
        return "to_number(" + operand + ")";
3✔
68
    }
69

70
    @Override
71
    public String formatToCharFunction(String operand, String format) {
72
        return "to_char(" + operand + ", " + format + ")";
4✔
73
    }
74

75
    @Override
76
    public String formatSubstringFunction(String operand, int startPos, int length) {
77
        return "substr(" + operand + ", " + startPos + ", " + length + ")";
5✔
78
    }
79

80
    @Override
81
    public String formatConcatFunction(List<String> operands) {
82
        // Note! The concat infix operator is used in output SQL
83
        return "concat(%s)".formatted(String.join(", ", operands));
×
84
    }
85

86
    @Override
87
    public String formatLengthFunction(String operand) {
88
        return "char_length(" + operand + ")";
3✔
89
    }
90

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

96
    @Override
97
    public String formatRoundFunction(String operand) {
98
        return "round(" + operand + ")";
3✔
99
    }
100

101
    @Override
102
    public String formatModuloFunction(String divisor, String dividend) {
103
        return "mod(" + divisor + ", " + dividend + ")";
4✔
104
    }
105

106
    @Override
107
    public String formatCurrentDateFunction() {
108
        return "current_date";
2✔
109
    }
110

111
    @Override
112
    public Optional<String> getConcatOperator() {
113
        return Optional.of("||");
3✔
114
    }
115

116
    @Override
117
    public boolean supports(Capability capability) {
118
        return SUPPORTED_CAPS.contains(capability);
4✔
119
    }
120
}
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