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

torand / FasterSQL / 13389227868

18 Feb 2025 11:10AM UTC coverage: 59.667% (+0.9%) from 58.785%
13389227868

push

github

torand
test: H2 specific testing of select and insert clauses

157 of 346 branches covered (45.38%)

Branch coverage included in aggregate %.

846 of 1335 relevant lines covered (63.37%)

3.35 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.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.util.lang.StringHelper.generate;
25

26
public class PostgreSqlDialect implements Dialect {
×
27
    private static final EnumSet<Capability> SUPPORTED_CAPS = EnumSet.of(LIMIT_OFFSET, CONCAT_OPERATOR);
×
28

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

34
    @Override
35
    public boolean offsetBeforeLimit() {
36
        return true;
×
37
    }
38

39
    @Override
40
    public Optional<String> formatRowOffsetClause() {
41
        return Optional.of("offset ?");
×
42
    }
43

44
    @Override
45
    public Optional<String> formatRowLimitClause() {
46
        return Optional.of("limit ?");
×
47
    }
48

49
    @Override
50
    public Optional<String> formatRowNumLiteral() {
51
        return Optional.empty();
×
52
    }
53

54
    @Override
55
    public String formatToNumberFunction(String operand, int precision, int scale) {
56
        StringBuilder mask = new StringBuilder();
×
57
        if (precision-scale > 0) {
×
58
            mask.append(generate("9", precision-scale));
×
59
        }
60
        if (scale > 0) {
×
61
            mask.append(".").append(generate("9", scale));
×
62
        }
63

64
        return "to_number(" + operand + ", '" + mask + "')";
×
65
    }
66

67
    @Override
68
    public String formatSubstringFunction(String operand, int startPos, int length) {
69
        return "substring(" + operand + ", " + startPos + ", " + length + ")";
×
70
    }
71

72
    @Override
73
    public String formatConcatFunction(List<String> operands) {
74
        throw new UnsupportedOperationException("Use the concat infix operator for PostgreSql");
×
75
    }
76

77
    @Override
78
    public String formatLengthFunction(String operand) {
79
        return "char_length(" + operand + ")";
×
80
    }
81

82
    @Override
83
    public boolean supports(Capability capability) {
84
        return SUPPORTED_CAPS.contains(capability);
×
85
    }
86
}
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