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

torand / FasterSQL / 13316818541

13 Feb 2025 08:49PM UTC coverage: 56.762%. First build
13316818541

Pull #8

github

web-flow
Merge a7d313d14 into 1f252c094
Pull Request #8: feat: misc additions

143 of 336 branches covered (42.56%)

Branch coverage included in aggregate %.

97 of 171 new or added lines in 34 files covered. (56.73%)

772 of 1276 relevant lines covered (60.5%)

3.21 hits per line

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

0.0
/src/main/java/io/github/torand/fastersql/dialect/PostgreSqlDialect.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.Optional;
20

21
import static io.github.torand.fastersql.dialect.Capability.LIMIT_OFFSET;
22
import static io.github.torand.fastersql.util.lang.StringHelper.generate;
23

24
public class PostgreSqlDialect implements Dialect {
×
25
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET);
×
26

27
    @Override
28
    public String getProductName() {
29
        return "PostgreSQL";
×
30
    }
31

32
    @Override
33
    public Optional<String> formatRowOffsetClause() {
NEW
34
        return Optional.of("offset ?");
×
35
    }
36

37
    @Override
38
    public Optional<String> formatRowLimitClause() {
NEW
39
        return Optional.of("limit ?");
×
40
    }
41

42
    @Override
43
    public Optional<String> formatRowNumLiteral() {
44
        return Optional.empty();
×
45
    }
46

47
    @Override
48
    public String formatToNumberFunction(String operand, int precision, int scale) {
49
        StringBuilder mask = new StringBuilder();
×
50
        if (precision-scale > 0) {
×
51
            mask.append(generate("9", precision-scale));
×
52
        }
53
        if (scale > 0) {
×
54
            mask.append(".").append(generate("9", scale));
×
55
        }
56

57
        return "to_number(" + operand + ", '" + mask + "')";
×
58
    }
59

60
    @Override
61
    public String formatSubstringFunction(String operand, int startPos, int length) {
NEW
62
        return "substring(" + operand + ", " + startPos + ", " + length + ")";
×
63
    }
64

65
    @Override
66
    public boolean supports(Capability capability) {
67
        return SUPPORTED_CAPS.contains(capability);
×
68
    }
69
}
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