• 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.0
/src/main/java/io/github/torand/fastersql/Table.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.TableAlias;
19

20
import static io.github.torand.fastersql.Command.SELECT;
21
import static io.github.torand.fastersql.util.contract.Requires.requireNonBlank;
22

23
public abstract class Table<ENTITY extends Table<?>> {
24
    private final String name;
25
    private final TableAlias alias;
26
    private final TableFactory<ENTITY> tableFactory;
27

28
    protected Table(String name, TableFactory<ENTITY> tableFactory) {
×
29
        this.name = requireNonBlank(name, "No name specified");
×
30
        this.alias = defaultAlias(name);
×
31
        this.tableFactory = tableFactory;
×
32
    }
×
33

34
    protected Table(String name, String alias, TableFactory<ENTITY> tableFactory) {
2✔
35
        this.name = requireNonBlank(name, "No name specified");
7✔
36
        this.alias = new TableAlias(requireNonBlank(alias, "No alias specified"));
10✔
37
        this.tableFactory = tableFactory;
3✔
38
    }
1✔
39

40
    public ENTITY as(String alias) {
41
        return tableFactory.newInstance(alias);
6✔
42
    }
43

44
    public Column column(String name) {
45
        return new Column(this, name);
6✔
46
    }
47

48
    public String name() {
49
        return name;
3✔
50
    }
51

52
    public String alias() {
53
        return alias.name();
4✔
54
    }
55

56
    public String sql(Context context) {
57
        if (context.isCommand(SELECT)) {
4✔
58
            return name + " " + alias.sql(context);
8✔
59
        } else {
60
            return name;
3✔
61
        }
62
    }
63

64
    private TableAlias defaultAlias(String name) {
NEW
65
        return new TableAlias(name);
×
66
    }
67

68
    @FunctionalInterface
69
    public interface TableFactory<ENTITY> {
70
        ENTITY newInstance(String alias);
71
    }
72
}
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