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

future-architect / uroborosql / #764

13 Aug 2024 03:26PM UTC coverage: 91.218% (+0.02%) from 91.197%
#764

Pull #331

HidekiSugimoto189
add oracle v12-23 and Mariadb 5,10 dialect
Pull Request #331: add oracle v12-23 and Mariadb 5,10 dialect

43 of 46 new or added lines in 8 files covered. (93.48%)

288 existing lines in 22 files now uncovered.

8787 of 9633 relevant lines covered (91.22%)

0.91 hits per line

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

86.84
/src/main/java/jp/co/future/uroborosql/client/command/GenerateCommand.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.command;
8

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

12
import org.jline.reader.LineReader;
13
import org.jline.terminal.Terminal;
14
import org.slf4j.Logger;
15
import org.slf4j.LoggerFactory;
16

17
import jp.co.future.uroborosql.client.completer.SqlKeywordCompleter;
18
import jp.co.future.uroborosql.client.completer.SqlKeywordCompleter.SqlKeyword;
19
import jp.co.future.uroborosql.client.completer.TableNameCompleter;
20
import jp.co.future.uroborosql.config.SqlConfig;
21
import jp.co.future.uroborosql.context.ExecutionContext;
22
import jp.co.future.uroborosql.mapping.MetaTable;
23
import jp.co.future.uroborosql.mapping.Table;
24
import jp.co.future.uroborosql.mapping.TableMetadata;
25

26
/**
27
 * Generate sql template Command
28
 *
29
 * @author H.Sugimoto
30
 */
31
public class GenerateCommand extends ReplCommand {
32
        /** REPLロガー */
33
        private static final Logger REPL_LOG = LoggerFactory.getLogger("jp.co.future.uroborosql.repl");
1✔
34

35
        /**
36
         * Constructor
37
         */
38
        @SuppressWarnings("unchecked")
39
        public GenerateCommand() {
40
                super(false, SqlKeywordCompleter.class, TableNameCompleter.class);
1✔
41
        }
1✔
42

43
        /**
44
         * {@inheritDoc}
45
         *
46
         * @see jp.co.future.uroborosql.client.command.ReplCommand#execute(org.jline.reader.LineReader, java.lang.String[], jp.co.future.uroborosql.config.SqlConfig, java.util.Properties)
47
         */
48
        @Override
49
        public boolean execute(final LineReader reader, final String[] parts, final SqlConfig sqlConfig,
50
                        final Properties props) {
51
                var writer = reader.getTerminal().writer();
1✔
52

53
                if (parts.length < 3) {
1✔
UNCOV
54
                        writer.println(toString() + " parameter missing. " + toString() + " [SQL_KEYWORD] [TABLE NAME].");
×
UNCOV
55
                        return true;
×
56
                }
57

58
                try (var agent = sqlConfig.agent()) {
1✔
59
                        var sqlKeyword = SqlKeyword.of(parts[1]);
1✔
60
                        var tableName = parts[2];
1✔
61
                        var versionColumnName = props.getProperty("sql.versionColumnName");
1✔
62
                        var optimisticLockSupplier = props
1✔
63
                                        .getProperty("sql.optimisticLockSupplier",
1✔
64
                                                        "jp.co.future.uroborosql.mapping.LockVersionOptimisticLockSupplier");
65

66
                        Table table = new MetaTable(tableName, null, versionColumnName, optimisticLockSupplier);
1✔
67
                        var metadata = TableMetadata.createTableEntityMetadata(agent, table);
1✔
68
                        metadata.setSchema(null);
1✔
69

70
                        ExecutionContext ctx = null;
1✔
71
                        if (sqlKeyword.isPresent()) {
1✔
72
                                var keyword = sqlKeyword.get();
1✔
73
                                switch (keyword) {
1✔
74
                                case INSERT:
75
                                        ctx = sqlConfig.getEntityHandler().createInsertContext(agent, metadata, null);
1✔
76
                                        break;
1✔
77

78
                                case UPDATE:
79
                                        ctx = sqlConfig.getEntityHandler().createUpdateContext(agent, metadata, null, true);
1✔
80
                                        break;
1✔
81

82
                                case DELETE:
83
                                        ctx = sqlConfig.getEntityHandler().createDeleteContext(agent, metadata, null, true);
1✔
84
                                        break;
1✔
85

86
                                default:
87
                                        ctx = sqlConfig.getEntityHandler().createSelectContext(agent, metadata, null, true);
1✔
88
                                        break;
89
                                }
90
                        } else {
1✔
UNCOV
91
                                ctx = sqlConfig.getEntityHandler().createSelectContext(agent, metadata, null, true);
×
92
                        }
93
                        writer.println(ctx.getSql());
1✔
UNCOV
94
                } catch (SQLException ex) {
×
UNCOV
95
                        REPL_LOG.error(ex.getMessage(), ex);
×
96
                }
1✔
97

98
                writer.flush();
1✔
99

100
                return true;
1✔
101
        }
102

103
        /**
104
         * {@inheritDoc}
105
         *
106
         * @see jp.co.future.uroborosql.client.command.ReplCommand#showHelp(org.jline.terminal.Terminal)
107
         */
108
        @Override
109
        public void showHelp(final Terminal terminal) {
110
                terminal.writer().println("\t" + this.toString() + ": generate sql to access the table.");
1✔
111
                terminal.writer().println(
1✔
112
                                "\t\tex) generate [select/insert/update/delete] [table name]<Enter> : Show sql to access tables according to keywords.");
113
        }
1✔
114
}
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