• 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

80.95
/src/main/java/io/github/torand/fastersql/dialect/SqlServerDialect.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.LIMIT_OFFSET;
24
import static io.github.torand.fastersql.dialect.Capability.MODULO_OPERATOR;
25
import static io.github.torand.fastersql.dialect.Capability.TRUNCATE_TABLE;
26

27
/**
28
 * Defines the SQL Server dialect.
29
 *
30
 * <a href="https://learn.microsoft.com/en-us/sql/sql-server/?view=sql-server-ver16" />
31
 */
32
public class SqlServerDialect implements Dialect {
33
    private final EnumSet<Capability> supportedCaps;
34

35
    public SqlServerDialect() {
36
        this(EnumSet.of(LIMIT_OFFSET, CONCAT_OPERATOR, MODULO_OPERATOR, TRUNCATE_TABLE));
7✔
37
    }
1✔
38

39
    private SqlServerDialect(EnumSet<Capability> capabilities) {
2✔
40
        this.supportedCaps = EnumSet.copyOf(capabilities);
4✔
41
    }
1✔
42

43
    @Override
44
    public String getProductName() {
45
        return "SQL Server";
2✔
46
    }
47

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

53
    /**
54
     * Row offset clause is supported from SQL Server 2012 onwards
55
     */
56
    @Override
57
    public Optional<String> formatRowOffsetClause() {
58
        return Optional.of("offset ? rows");
3✔
59
    }
60

61
    /**
62
     * Row limit clause is supported from SQL Server 2012 onwards
63
     */
64
    @Override
65
    public Optional<String> formatRowLimitClause() {
66
        return Optional.of("fetch next ? rows only");
3✔
67
    }
68

69
    /**
70
     * SQL Server has the ROW_NUMBER() function but must be combined with OVER() in this context.
71
     */
72
    @Override
73
    public Optional<String> formatRowNumLiteral() {
UNCOV
74
        return Optional.empty();
×
75
    }
76

77
    @Override
78
    public String formatToNumberFunction(String operand, int precision, int scale) {
79
        return "cast(" + operand + " as numeric(" + precision + "," + scale + "))";
5✔
80
    }
81

82
    @Override
83
    public String formatToCharFunction(String operand, String format) {
UNCOV
84
        throw new UnsupportedOperationException("SQL Server does not support the to_char() function");
×
85
    }
86

87
    @Override
88
    public String formatSubstringFunction(String operand, int startPos, int length) {
89
        return "substring(" + operand + ", " + startPos + ", " + length + ")";
5✔
90
    }
91

92
    @Override
93
    public String formatConcatFunction(List<String> operands) {
UNCOV
94
        throw new UnsupportedOperationException("SQL Server does not support the concat() function (use the concat infix operator instead)");
×
95
    }
96

97
    @Override
98
    public String formatLengthFunction(String operand) {
99
        return "len(" + operand + ")";
3✔
100
    }
101

102
    @Override
103
    public String formatCeilFunction(String operand) {
104
        return "ceiling(" + operand + ")";
3✔
105
    }
106

107
    @Override
108
    public String formatRoundFunction(String operand) {
109
        return "round(" + operand + ", 0)";
3✔
110
    }
111

112
    @Override
113
    public String formatModuloFunction(String divisor, String dividend) {
UNCOV
114
        throw new UnsupportedOperationException("SQL Server does not support the mod() function (use the modulo infix operator instead)");
×
115
    }
116

117
    @Override
118
    public String formatCurrentDateFunction() {
119
        return "getdate()";
2✔
120
    }
121

122
    @Override
123
    public Optional<String> getConcatOperator() {
124
        return Optional.of("+");
3✔
125
    }
126

127
    @Override
128
    public boolean supports(Capability capability) {
129
        return supportedCaps.contains(capability);
5✔
130
    }
131
}
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