• 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

70.83
/src/main/java/io/github/torand/fastersql/Column.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;
17

18
import io.github.torand.fastersql.alias.ColumnAlias;
19
import io.github.torand.fastersql.expression.Expression;
20
import io.github.torand.fastersql.order.OrderExpression;
21
import io.github.torand.fastersql.predicate.LeftOperand;
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.Command.SELECT;
28
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
29
import static java.util.Objects.requireNonNull;
30

31
public class Column implements LeftOperand, Expression, OrderExpression {
32
    private final Table<?> table;
33
    private final String name;
34
    private final ColumnAlias alias;
35

36
    public Column(Table<?> table, String name) {
2✔
37
        this.table = requireNonNull(table, "No table specified");
6✔
38
        this.name = requireNonBlank(name, "No name specified");
7✔
39
        this.alias = defaultAlias(table, name);
6✔
40
    }
1✔
41

NEW
42
    private Column(Table<?> table, String name, String alias) {
×
43
        this.table = requireNonNull(table, "No table specified");
×
44
        this.name = requireNonBlank(name, "No name specified");
×
NEW
45
        this.alias = new ColumnAlias(requireNonBlank(alias, "No alias specified"));
×
NEW
46
    }
×
47

48
    public Join on(Column other) {
49
        return new Join(this, other);
6✔
50
    }
51

52
    public String name() {
NEW
53
        return name;
×
54
    }
55

56
    public Table<?> table() {
57
        return table;
3✔
58
    }
59

60
    // Sql
61

62
    @Override
63
    public String sql(Context context) {
64
        if (context.isCommand(SELECT)) {
4✔
65
            return table.alias() + "." + name;
7✔
66
        } else {
67
            return name;
3✔
68
        }
69
    }
70

71
    @Override
72
    public Stream<Object> params(Context context) {
73
        return Stream.empty();
2✔
74
    }
75

76
    @Override
77
    public Stream<Column> columnRefs() {
78
        return Stream.of(this);
3✔
79
    }
80

81
    @Override
82
    public Stream<ColumnAlias> aliasRefs() {
83
        return Stream.of(alias);
4✔
84
    }
85

86
    // Projection
87

88
    @Override
89
    public Projection as(String alias) {
NEW
90
        return new Column(table, name, alias);
×
91
    }
92

93
    @Override
94
    public Optional<ColumnAlias> alias() {
95
        return Optional.ofNullable(alias);
4✔
96
    }
97

98
    private ColumnAlias defaultAlias(Table<?> table, String name) {
99
        return new ColumnAlias((table.alias() + "_" + name).toUpperCase());
9✔
100
    }
101
}
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