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

future-architect / uroborosql / #743

28 Jun 2024 04:17PM UTC coverage: 90.988% (+0.5%) from 90.484%
#743

push

web-flow
add paramIfNotEmpty method (#318)

* v0.x to master merge

* fix nanoseconds diff (java8 to java11)

* eclipse cleanup and  optimize import

* eclipse format

* optimize Imports

* remove unused annotation

* library version up

* migrate v0.x to master
- update java version 8 to 11
- update junit4 to junit5
- library version update

* fix test failed

* remove unused annotation

* fixed bug

* use var

* fix java8 coding style

* Refactoring TransactionContextManager

* Refactoring SqlAgent

* 途中コミット

* fix testcase

* fix review

* fix javadoc comments

* merge v0.x PR

* cleanup code

* cleanup test code

* change build status badge

* - agent.query, update, proc, batch にそれぞれSupplierを引数にとるメソッドを追加
- SqlQuery.paramとSqlEntityUpdate.setにFunctionを受け取るメソッドを追加

* testcaseの整形

* - SqlFluent と ExtractionCondition の分離
- Arrays.asList -> List.of への変更
- テストの整形

* - v0.x系の不具合対応の追いつき
- ログ出力の整理

* - SqlKindの整理(ENTITY_XXXの追加)
- REPL_LOGの追加
- Deprecatedメソッドの削除(SqlAgent)
- SqlAgent, ExecutionContextでsetterをfluent APIに変更

* DB接続URLの修正

* add and fix testcases.

* add event testcases.

* fix typo

* add paramIfNotEmpty method and StringUtils rename ObjectUtils

* fix review comments.

* remove unused import

1695 of 1958 new or added lines in 97 files covered. (86.57%)

26 existing lines in 10 files now uncovered.

8249 of 9066 relevant lines covered (90.99%)

0.91 hits per line

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

84.85
/src/main/java/jp/co/future/uroborosql/client/completer/TableNameCompleter.java
1
/**
2
 * Copyright (c) 2017-present, Future Corporation
3
 *
4
 * This source code is licensed under the MIT license found in the
5
 * LICENSE file in the root directory of this source tree.
6
 */
7
package jp.co.future.uroborosql.client.completer;
8

9
import java.sql.SQLException;
10
import java.util.List;
11

12
import org.jline.reader.Candidate;
13
import org.jline.reader.LineReader;
14
import org.jline.reader.ParsedLine;
15
import org.slf4j.Logger;
16
import org.slf4j.LoggerFactory;
17

18
import jp.co.future.uroborosql.client.command.ReplCommand;
19
import jp.co.future.uroborosql.connection.ConnectionSupplier;
20

21
/**
22
 * テーブル名を補完するCompleter
23
 *
24
 * @author H.Sugimoto
25
 *
26
 */
27
public class TableNameCompleter extends AbstractCompleter {
28
        /** REPLロガー */
29
        private static final Logger REPL_LOG = LoggerFactory.getLogger("jp.co.future.uroborosql.repl");
1✔
30

31
        /** Connectionサプライヤ. */
32
        private final ConnectionSupplier connectionSupplier;
33

34
        /**
35
         * Constructor
36
         *
37
         * @param commands ReplCommand List
38
         * @param connectionSupplier connectionSupplier
39
         */
40
        public TableNameCompleter(final List<ReplCommand> commands, final ConnectionSupplier connectionSupplier) {
41
                super(commands);
1✔
42
                this.connectionSupplier = connectionSupplier;
1✔
43
        }
1✔
44

45
        /**
46
         * DatabaseMetadataからテーブル名を取得して補完候補とする。
47
         *
48
         * {@inheritDoc}
49
         *
50
         * @see org.jline.reader.Completer#complete(org.jline.reader.LineReader, org.jline.reader.ParsedLine, java.util.List)
51
         */
52
        @Override
53
        public void complete(final LineReader reader, final ParsedLine line, final List<Candidate> candidates) {
54
                var buffer = line.line().substring(0, line.cursor());
1✔
55
                var parts = getLineParts(buffer);
1✔
56
                var len = parts.length;
1✔
57

58
                // コード補完する引数の番号を特定。
59
                var startArgNo = getStartArgNo(line);
1✔
60

61
                // 対象引数が-1、または開始引数にlenが満たない場合は該当なしなのでコード補完しない
62
                if (!accept(startArgNo, buffer, len)) {
1✔
63
                        return;
1✔
64
                }
65

66
                var isBlank = buffer.endsWith(" ");
1✔
67
                var tableNamePattern = "%";
1✔
68
                if (len == startArgNo && isBlank) {
1✔
69
                        tableNamePattern = "%";
1✔
70
                } else if (len == startArgNo + 1 && !isBlank) {
1✔
71
                        tableNamePattern = parts[len - 1] + "%";
1✔
72
                } else {
73
                        return;
×
74
                }
75

76
                try {
77
                        var conn = connectionSupplier.getConnection();
1✔
78
                        var md = conn.getMetaData();
1✔
79
                        try (var rs = md.getTables(conn.getCatalog(), conn.getSchema(),
1✔
80
                                        tableNamePattern.toUpperCase(), null)) {
1✔
81
                                while (rs.next()) {
1✔
82
                                        candidates.add(new Candidate(rs.getString("TABLE_NAME")));
1✔
83
                                }
84
                        }
85
                        if (candidates.isEmpty()) {
1✔
86
                                try (var rs = md.getTables(conn.getCatalog(), conn.getSchema(),
1✔
87
                                                tableNamePattern.toLowerCase(), null)) {
1✔
88
                                        while (rs.next()) {
1✔
89
                                                candidates.add(new Candidate(rs.getString("TABLE_NAME")));
×
90
                                        }
91
                                }
92
                        }
93
                } catch (SQLException ex) {
×
NEW
94
                        REPL_LOG.error(ex.getMessage(), ex);
×
95
                        return;
×
96
                }
1✔
97
        }
1✔
98
}
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