• 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

94.74
/src/main/java/io/github/torand/fastersql/function/singlerow/Concat.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.singlerow;
17

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

25
import java.util.ArrayList;
26
import java.util.List;
27
import java.util.Optional;
28
import java.util.stream.Stream;
29

30
import static io.github.torand.fastersql.dialect.Capability.CONCAT_OPERATOR;
31
import static io.github.torand.fastersql.util.collection.CollectionHelper.streamSafely;
32
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
33
import static io.github.torand.fastersql.util.contract.Requires.requireNonEmpty;
34
import static io.github.torand.fastersql.util.lang.StringHelper.nonBlank;
35
import static java.util.stream.Collectors.joining;
36

37
public class Concat implements SingleRowFunction {
38
    private final List<Expression> expressions;
39
    private final ColumnAlias alias;
40

41
    Concat(List<Expression> expressions, String alias) {
2✔
42
        this.expressions = new ArrayList<>(requireNonEmpty(expressions, "No expression specified"));
10✔
43
        this.alias = nonBlank(alias) ? new ColumnAlias(alias) : defaultAlias();
12✔
44
    }
1✔
45

46
    // Sql
47

48
    @Override
49
    public String sql(Context context) {
50
        if (context.getDialect().supports(CONCAT_OPERATOR)) {
5✔
51
            return streamSafely(expressions).map(e -> e.sql(context)).collect(joining(" || "));
15✔
52
        }
53

54
        List<String> expressionsAsSql = streamSafely(expressions).map(e -> e.sql(context)).toList();
12✔
55
        return context.getDialect().formatConcatFunction(expressionsAsSql);
5✔
56
    }
57

58
    @Override
59
    public Stream<Object> params(Context context) {
60
        return streamSafely(expressions).flatMap(e -> e.params(context));
11✔
61
    }
62

63
    @Override
64
    public Stream<Column> columnRefs() {
65
        return streamSafely(expressions).flatMap(Sql::columnRefs);
6✔
66
    }
67

68
    @Override
69
    public Stream<ColumnAlias> aliasRefs() {
NEW
70
        return streamSafely(expressions).flatMap(Sql::aliasRefs);
×
71
    }
72

73
    // Projection
74

75
    @Override
76
    public Projection as(String alias) {
77
        requireNonBlank(alias, "No alias specified");
6✔
78
        return new Concat(expressions, alias);
7✔
79
    }
80

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

86
    private ColumnAlias defaultAlias() {
87
        return ColumnAlias.generate("CONCAT_");
3✔
88
    }
89
}
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