• 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

62.5
/src/main/java/io/github/torand/fastersql/order/Descending.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.order;
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.dialect.Capability;
22

23
import java.util.stream.Stream;
24

25
import static java.lang.Boolean.FALSE;
26
import static java.lang.Boolean.TRUE;
27
import static java.util.Objects.nonNull;
28
import static java.util.Objects.requireNonNull;
29

30
public class Descending implements Order {
31
    private final OrderExpression expression;
32
    private final Boolean nullsFirst;
33

34
    Descending(OrderExpression expression) {
35
        this(requireNonNull(expression, "No order expression specified"), null);
7✔
36
    }
1✔
37

38
    private Descending(OrderExpression expression, Boolean nullsFirst) {
2✔
39
        this.expression = expression;
3✔
40
        this.nullsFirst = nullsFirst;
3✔
41
    }
1✔
42

43
    public Descending nullsFirst() {
NEW
44
        return new Descending(expression, true);
×
45
    }
46

47
    public Descending nullsLast() {
NEW
48
        return new Descending(expression, false);
×
49
    }
50

51
    // Sql
52

53
    @Override
54
    public String sql(Context context) {
55
        if (nonNull(nullsFirst) && !context.getDialect().supports(Capability.NULL_ORDERING)) {
4!
56
            throw new UnsupportedOperationException("%s does not support 'nulls first' or 'nulls last'".formatted(context.getDialect().getProductName()));
×
57
        }
58

59
        return expression.sql(context) + " desc"
5✔
60
            + (TRUE.equals(nullsFirst) ? " nulls first" : "")
6!
61
            + (FALSE.equals(nullsFirst) ? " nulls last" : "");
7!
62
    }
63

64
    @Override
65
    public Stream<Object> params(Context context) {
66
        return Stream.empty();
×
67
    }
68

69
    @Override
70
    public Stream<Column> columnRefs() {
71
        return expression.columnRefs();
4✔
72
    }
73

74
    @Override
75
    public Stream<ColumnAlias> aliasRefs() {
76
        return expression.aliasRefs();
4✔
77
    }
78
}
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