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

torand / FasterSQL / 16990059345

15 Aug 2025 12:34PM UTC coverage: 66.782% (-6.6%) from 73.399%
16990059345

push

github

torand
chore: access central snapshots

294 of 598 branches covered (49.16%)

Branch coverage included in aggregate %.

1638 of 2295 relevant lines covered (71.37%)

3.83 hits per line

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

37.04
/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 io.github.torand.fastersql.function.singlerow.cast.DataType;
19

20
import java.util.EnumSet;
21
import java.util.List;
22
import java.util.Optional;
23

24
import static io.github.torand.fastersql.dialect.Capability.CONCAT_OPERATOR;
25
import static io.github.torand.fastersql.dialect.Capability.CURRENT_TIME;
26
import static io.github.torand.fastersql.dialect.Capability.FULL_OUTER_JOIN;
27
import static io.github.torand.fastersql.dialect.Capability.LIMIT_OFFSET;
28
import static io.github.torand.fastersql.dialect.Capability.MODULO_OPERATOR;
29
import static io.github.torand.fastersql.dialect.Capability.NULL_ORDERING;
30

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

37
    /**
38
     * Creates a SQLite {@link Dialect} implementation.
39
     */
40
    public SqliteDialect() {}
3✔
41

42
    @Override
43
    public String getProductName() {
44
        return "SQLite";
2✔
45
    }
46

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

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

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

62
    @Override
63
    public Optional<String> formatRowNumLiteral() {
64
        return Optional.of("row_number()");
×
65
    }
66

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

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

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

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

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

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

98
    @Override
99
    public String formatLnFunction(String operand) {
100
        return "ln(" + operand + ")";
3✔
101
    }
102

103
    @Override
104
    public String formatRoundFunction(String operand) {
105
        return "round(" + operand + ")";
3✔
106
    }
107

108
    @Override
109
    public String formatModuloFunction(String divisor, String dividend) {
110
        // Note! The modulo infix operator is used in output SQL
111
        return "mod(" + divisor + ", " + dividend + ")";
×
112
    }
113

114
    @Override
115
    public String formatCurrentDateFunction() {
116
        return "current_date";
2✔
117
    }
118

119
    @Override
120
    public Optional<String> getDataType(DataType dataType) {
121
        // https://www.sqlite.org/datatype3.html
122
        return Optional.ofNullable(switch(dataType.getIsoDataType()) {
8!
123
            case BOOLEAN -> "boolean";
×
124
            case CHAR -> "char";
×
125
            case VARCHAR -> "varchar";
2✔
126
            case BIT -> null;
×
127
            case BIT_VARYING -> null;
×
128
            case NUMERIC -> "numeric";
×
129
            case DECIMAL -> "decimal";
2✔
130
            case INTEGER -> "integer";
×
131
            case SMALLINT -> "smallint";
×
132
            case FLOAT -> "float";
×
133
            case DOUBLE_PRECISION -> "double precision";
×
134
            case REAL -> "real";
×
135
            case TIME -> null;
×
136
            case DATE -> "date";
×
137
            case INTERVAL -> null;
×
138
            case CHARACTER_LARGE_OBJECT -> "clob";
×
139
            case BINARY_LARGE_OBJECT -> "blob";
×
140
        });
141
    }
142

143
    @Override
144
    public Optional<String> getConcatOperator() {
145
        return Optional.of("||");
3✔
146
    }
147

148
    @Override
149
    public boolean supports(Capability capability) {
150
        return SUPPORTED_CAPS.contains(capability);
4✔
151
    }
152
}
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