• 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

70.59
/src/main/java/io/github/torand/fastersql/subquery/TableSubquery.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.alias.TableAlias;
20
import io.github.torand.fastersql.model.Column;
21
import io.github.torand.fastersql.relation.Relation;
22
import io.github.torand.fastersql.sql.Context;
23
import io.github.torand.fastersql.statement.SelectStatement;
24

25
import java.util.stream.Stream;
26

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

31
/**
32
 * Implements a subquery to be used in a FROM clause.
33
 */
34
public class TableSubquery implements Subquery, Relation {
35
    private final SelectStatement query;
36
    private final TableAlias alias;
37

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

47
    private TableSubquery(SelectStatement query, String alias) {
2✔
48
        this.query = requireNonNull(query, "No query specified");
6✔
49
        this.alias = new TableAlias(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) + ")" + (nonNull(alias) ? " " + alias.sql(context) : "");
16!
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();
×
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
    // Relation
82

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

88
    @Override
89
    public TableAlias alias() {
90
        return alias;
×
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