• 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

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 <a href="https://www.sqlite.org/lang.html">SQLite</a> SQL dialect.
30
 */
31
public class SqliteDialect implements Dialect {
32
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, CONCAT_OPERATOR, MODULO_OPERATOR, CURRENT_TIME, NULL_ORDERING);
8✔
33

34
    /**
35
     * Creates a SQLite {@link Dialect} implementation.
36
     */
37
    public SqliteDialect() {}
3✔
38

39
    @Override
40
    public String getProductName() {
41
        return "SQLite";
2✔
42
    }
43

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

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

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

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

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

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

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

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

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

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

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

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