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

torand / FasterSQL / 13392727978

18 Feb 2025 02:20PM UTC coverage: 59.964% (+0.2%) from 59.726%
13392727978

push

github

torand
chore: use more recent dep

158 of 346 branches covered (45.66%)

Branch coverage included in aggregate %.

850 of 1335 relevant lines covered (63.67%)

3.36 hits per line

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

66.67
/src/main/java/io/github/torand/fastersql/dialect/MySqlDialect.java
1
/*
2
 * Copyright (c) 2024 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.LIMIT_OFFSET;
23

24
/**
25
 * Defines the MySQL SQL dialect.
26
 *
27
 * <a href="https://dev.mysql.com/doc/refman/8.4/en/" />
28
 */
29
public class MySqlDialect implements Dialect {
3✔
30
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET);
4✔
31

32
    @Override
33
    public String getProductName() {
34
        return "MySQL";
2✔
35
    }
36

37
    @Override
38
    public boolean offsetBeforeLimit() {
39
        return false;
2✔
40
    }
41

42
    @Override
43
    public Optional<String> formatRowOffsetClause() {
44
        return Optional.of("offset ?");
3✔
45
    }
46

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

52
    @Override
53
    public Optional<String> formatRowNumLiteral() {
54
        return Optional.empty();
×
55
    }
56

57
    @Override
58
    public String formatToNumberFunction(String operand, int precision, int scale) {
59
        return "cast(" + operand + " as decimal(" + precision + "," + scale + "))";
×
60
    }
61

62
    @Override
63
    public String formatSubstringFunction(String operand, int startPos, int length) {
64
        return "substring(" + operand + ", " + startPos + ", " + length + ")";
5✔
65
    }
66

67
    @Override
68
    public String formatConcatFunction(List<String> operands) {
69
        return "concat(%s)".format(String.join(",", operands));
×
70
    }
71

72
    @Override
73
    public String formatLengthFunction(String operand) {
74
        return "char_length(" + operand + ")";
×
75
    }
76

77
    @Override
78
    public boolean supports(Capability capability) {
79
        return SUPPORTED_CAPS.contains(capability);
4✔
80
    }
81
}
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