• 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/MySqlDialect.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.CURRENT_TIME;
23
import static io.github.torand.fastersql.dialect.Capability.LIMIT_OFFSET;
24
import static io.github.torand.fastersql.dialect.Capability.MODULO_OPERATOR;
25
import static io.github.torand.fastersql.dialect.Capability.SELECT_FOR_UPDATE;
26
import static io.github.torand.fastersql.dialect.Capability.TRUNCATE_TABLE;
27

28
/**
29
 * Defines the MySQL SQL dialect.
30
 *
31
 * <a href="https://dev.mysql.com/doc/refman/8.4/en/" />
32
 */
33
public class MySqlDialect implements Dialect {
3✔
34
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, CURRENT_TIME, MODULO_OPERATOR, SELECT_FOR_UPDATE, TRUNCATE_TABLE);
8✔
35

36
    @Override
37
    public String getProductName() {
38
        return "MySQL";
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() {
UNCOV
58
        return Optional.empty();
×
59
    }
60

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

66
    @Override
67
    public String formatToCharFunction(String operand, String format) {
UNCOV
68
        throw new UnsupportedOperationException("MySQL does not support the to_char() function");
×
69
    }
70

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

76
    @Override
77
    public String formatConcatFunction(List<String> operands) {
78
        return "concat(%s)".formatted(String.join(", ", operands));
11✔
79
    }
80

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

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

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

96
    @Override
97
    public String formatModuloFunction(String divisor, String dividend) {
UNCOV
98
        throw new UnsupportedOperationException("MySQL does not support the mod() function (use the modulo infix operator instead)");
×
99
    }
100

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

106
    @Override
107
    public Optional<String> getConcatOperator() {
UNCOV
108
        return Optional.empty();
×
109
    }
110

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