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

torand / FasterSQL / 14972998308

12 May 2025 01:04PM UTC coverage: 67.475% (+0.3%) from 67.194%
14972998308

Pull #27

github

web-flow
Merge d0df0a4c0 into 1f1b3df71
Pull Request #27: feat: add support for SQL Server dialect

219 of 418 branches covered (52.39%)

Branch coverage included in aggregate %.

51 of 64 new or added lines in 13 files covered. (79.69%)

1144 of 1602 relevant lines covered (71.41%)

3.81 hits per line

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

72.22
/src/main/java/io/github/torand/fastersql/dialect/MariaDbDialect.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

27
/**
28
 * Defines the MAriaDB SQL dialect.
29
 *
30
 * <a href="https://mariadb.com/kb/en/sql-statements/" />
31
 */
32
public class MariaDbDialect implements Dialect {
3✔
33
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, CURRENT_TIME, MODULO_OPERATOR, SELECT_FOR_UPDATE);
7✔
34

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

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

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

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

55
    @Override
56
    public Optional<String> formatRowNumLiteral() {
57
        return Optional.empty();
×
58
    }
59

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

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

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

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

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

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

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

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

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

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

110
    @Override
111
    public boolean supports(Capability capability) {
112
        return SUPPORTED_CAPS.contains(capability);
4✔
113
    }
114
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc