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

torand / FasterSQL / 13591799490

28 Feb 2025 03:59PM UTC coverage: 65.237% (-1.3%) from 66.563%
13591799490

push

github

web-flow
Merge pull request #14 from torand/having-support

feat: supporting the HAVING clause + IS NULL operator now supports an…

214 of 408 branches covered (52.45%)

Branch coverage included in aggregate %.

273 of 389 new or added lines in 69 files covered. (70.18%)

3 existing lines in 3 files now uncovered.

1079 of 1574 relevant lines covered (68.55%)

3.68 hits per line

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

75.0
/src/main/java/io/github/torand/fastersql/function/aggregate/CountAll.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.function.aggregate;
17

18
import io.github.torand.fastersql.Column;
19
import io.github.torand.fastersql.Context;
20
import io.github.torand.fastersql.alias.ColumnAlias;
21
import io.github.torand.fastersql.order.Order;
22
import io.github.torand.fastersql.projection.Projection;
23

24
import java.util.Optional;
25
import java.util.stream.Stream;
26

27
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
28
import static io.github.torand.fastersql.util.lang.StringHelper.nonBlank;
29

30
public class CountAll implements AggregateFunction {
31
    private final ColumnAlias alias;
32

33
    CountAll(String alias) {
2✔
34
        this.alias = nonBlank(alias) ? new ColumnAlias(alias) : defaultAlias();
12✔
35
    }
1✔
36

37
    // Sql
38

39
    @Override
40
    public String sql(Context context) {
41
        return "count(*)";
2✔
42
    }
43

44
    @Override
45
    public Stream<Object> params(Context context) {
46
        return Stream.empty();
2✔
47
    }
48

49
    @Override
50
    public Stream<Column> columnRefs() {
51
        return Stream.empty();
2✔
52
    }
53

54
    @Override
55
    public Stream<ColumnAlias> aliasRefs() {
NEW
56
        return Stream.empty();
×
57
    }
58

59
    // Projection
60

61
    @Override
62
    public Projection as(String alias) {
63
        requireNonBlank(alias, "No alias specified");
6✔
64
        return new CountAll(alias);
5✔
65
    }
66

67
    @Override
68
    public Optional<ColumnAlias> alias() {
69
        return Optional.ofNullable(alias);
4✔
70
    }
71

72
    // OrderExpression
73

74
    @Override
75
    public Order ascIf(boolean condition) {
76
        throw new UnsupportedOperationException("The 'count(*)' function can't be used in an 'order by' clause");
×
77
    }
78

79
    @Override
80
    public Order asc() {
81
        throw new UnsupportedOperationException("The 'count(*)' function can't be used in an 'order by' clause");
×
82
    }
83

84
    @Override
85
    public Order desc() {
86
        throw new UnsupportedOperationException("The 'count(*)' function can't be used in an 'order by' clause");
×
87
    }
88

89
    private ColumnAlias defaultAlias() {
90
        return new ColumnAlias("COUNT_ALL");
5✔
91
    }
92
}
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