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

torand / FasterSQL / 15346133148

30 May 2025 11:50AM UTC coverage: 70.397% (+0.1%) from 70.298%
15346133148

push

github

torand
chore: test javadoc publish

235 of 420 branches covered (55.95%)

Branch coverage included in aggregate %.

1237 of 1671 relevant lines covered (74.03%)

3.9 hits per line

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

86.67
/src/main/java/io/github/torand/fastersql/subquery/ExpressionSubquery.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.subquery;
17

18
import io.github.torand.fastersql.alias.ColumnAlias;
19
import io.github.torand.fastersql.expression.Expression;
20
import io.github.torand.fastersql.model.Column;
21
import io.github.torand.fastersql.projection.Projection;
22
import io.github.torand.fastersql.sql.Context;
23
import io.github.torand.fastersql.statement.SelectStatement;
24

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

28
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
29
import static java.util.Objects.requireNonNull;
30

31
/**
32
 * Implements a subquery to be used as projection or as operand for a predicate.
33
 */
34
public class ExpressionSubquery implements Subquery, Expression {
35
    private final SelectStatement query;
36
    private final ColumnAlias alias;
37

38
    /**
39
     * Creates an expression subquery.
40
     * @param query the query.
41
     */
42
    public ExpressionSubquery(SelectStatement query) {
2✔
43
        this.query = requireNonNull(query, "No query specified");
6✔
44
        this.alias = null;
3✔
45
    }
1✔
46

47
    private ExpressionSubquery(SelectStatement query, String alias) {
2✔
48
        this.query = requireNonNull(query, "No query specified");
6✔
49
        this.alias = new ColumnAlias(requireNonBlank(alias, "No alias specified"));
10✔
50
    }
1✔
51

52
    // Sql
53

54
    @Override
55
    public String sql(Context context) {
56
        return "(" + query.sql(context) + ")";
6✔
57
    }
58

59
    @Override
60
    public Stream<Object> params(Context context) {
61
        return query.params(context);
5✔
62
    }
63

64
    @Override
65
    public Stream<Column> columnRefs() {
66
        return Stream.empty();
2✔
67
    }
68

69
    @Override
70
    public Stream<ColumnAlias> aliasRefs() {
71
        return Stream.empty();
×
72
    }
73

74
    // Subquery
75

76
    @Override
77
    public SelectStatement query() {
78
        return query;
×
79
    }
80

81
    // Projection
82

83
    @Override
84
    public Projection as(String alias) {
85
        return new ExpressionSubquery(query, alias);
7✔
86
    }
87

88
    @Override
89
    public Optional<ColumnAlias> alias() {
90
        return Optional.ofNullable(alias);
4✔
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