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

torand / FasterSQL / 15299276026

28 May 2025 11:44AM UTC coverage: 70.298% (+0.2%) from 70.078%
15299276026

push

github

web-flow
Merge pull request #32 from torand/hsqldb-support

feat: add support for HSQLDB dialect

235 of 420 branches covered (55.95%)

Branch coverage included in aggregate %.

18 of 20 new or added lines in 2 files covered. (90.0%)

1230 of 1664 relevant lines covered (73.92%)

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

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

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

47
    @Override
48
    public Optional<String> formatRowOffsetClause() {
49
        return Optional.of("offset ?");
3✔
50
    }
51

52
    @Override
53
    public Optional<String> formatRowLimitClause() {
54
        return Optional.of("limit ?");
3✔
55
    }
56

57
    @Override
58
    public Optional<String> formatRowNumLiteral() {
NEW
59
        return Optional.of("rownum()");
×
60
    }
61

62
    @Override
63
    public String formatToNumberFunction(String operand, int precision, int scale) {
64
        return "to_number(" + operand + ")";
3✔
65
    }
66

67
    @Override
68
    public String formatToCharFunction(String operand, String format) {
69
        return "to_char(" + operand + ", " + format + ")";
4✔
70
    }
71

72
    @Override
73
    public String formatSubstringFunction(String operand, int startPos, int length) {
74
        return "substr(" + operand + ", " + startPos + ", " + length + ")";
5✔
75
    }
76

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

83
    @Override
84
    public String formatLengthFunction(String operand) {
85
        return "char_length(" + operand + ")";
3✔
86
    }
87

88
    @Override
89
    public String formatCeilFunction(String operand) {
90
        return "ceil(" + operand + ")";
3✔
91
    }
92

93
    @Override
94
    public String formatRoundFunction(String operand) {
95
        return "round(" + operand + ")";
3✔
96
    }
97

98
    @Override
99
    public String formatModuloFunction(String divisor, String dividend) {
100
        return "mod(" + divisor + ", " + dividend + ")";
4✔
101
    }
102

103
    @Override
104
    public String formatCurrentDateFunction() {
105
        return "current_date";
2✔
106
    }
107

108
    @Override
109
    public Optional<String> getConcatOperator() {
110
        return Optional.of("||");
3✔
111
    }
112

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