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

torand / FasterSQL / 15294773771

28 May 2025 08:01AM UTC coverage: 70.078% (+0.2%) from 69.877%
15294773771

Pull #31

github

web-flow
Merge 9f1c324c0 into 6be86da23
Pull Request #31: feat: add support for SQLite dialect

233 of 418 branches covered (55.74%)

Branch coverage included in aggregate %.

28 of 33 new or added lines in 12 files covered. (84.85%)

45 existing lines in 10 files now uncovered.

1212 of 1644 relevant lines covered (73.72%)

3.91 hits per line

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

77.78
/src/main/java/io/github/torand/fastersql/dialect/SqliteDialect.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.MODULO_OPERATOR;
26
import static io.github.torand.fastersql.dialect.Capability.NULL_ORDERING;
27

28
/**
29
 * Defines the SQLite SQL dialect.
30
 *
31
 * <a href="https://www.sqlite.org/lang.html" />
32
 */
33
public class SqliteDialect implements Dialect {
3✔
34
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, CONCAT_OPERATOR, MODULO_OPERATOR, CURRENT_TIME, NULL_ORDERING);
8✔
35

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

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

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

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

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

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

66
    @Override
67
    public String formatToCharFunction(String operand, String format) {
NEW
68
        throw new UnsupportedOperationException("SQLite does not support the to_char() function (timestamps are already stored as ISO8601 strings)");
×
69
    }
70

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

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

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

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

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

97
    @Override
98
    public String formatModuloFunction(String divisor, String dividend) {
99
        // Note! The modulo infix operator is used in output SQL
NEW
100
        return "mod(" + divisor + ", " + dividend + ")";
×
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