Skip to content

Commit ec8ed08

Browse files
committed
Fix reviewdog
1 parent 611b013 commit ec8ed08

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

usecase/sqlite3.go

+9-13
Original file line numberDiff line numberDiff line change
@@ -60,39 +60,35 @@ func (si *SQLite3Interactor) Exec(ctx context.Context, statement string) (int64,
6060
return si.Repository.Exec(ctx, statement)
6161
}
6262

63-
// ExecSQL execute "SELECT/EXPLAIN"query or "INSERT/UPDATE/DELETE" statement
63+
// ExecSQL executes "SELECT/EXPLAIN" query or "INSERT/UPDATE/DELETE" statement
6464
func (si *SQLite3Interactor) ExecSQL(ctx context.Context, statement string) (*model.Table, int64, error) {
6565
argv := strings.Split(trimWordGaps(statement), " ")
6666

6767
// NOTE: SQLY uses SQLite3. There is some SQL that can be changed from non-support
6868
// to support in the future. Currently, it is not supported because it is not needed
6969
// for developer ( == me:) ) use cases.
70-
if si.sql.isDDL(argv[0]) {
70+
switch {
71+
case si.sql.isDDL(argv[0]):
7172
return nil, 0, errors.New("not support data definition language: " + strings.Join(si.sql.ddl, ", "))
72-
}
73-
if si.sql.isTCL(argv[0]) {
73+
case si.sql.isTCL(argv[0]):
7474
return nil, 0, errors.New("not support transaction control language: " + strings.Join(si.sql.tcl, ", "))
75-
}
76-
if si.sql.isDCL(argv[0]) {
75+
case si.sql.isDCL(argv[0]):
7776
return nil, 0, errors.New("not support data control language: " + strings.Join(si.sql.dcl, ", "))
78-
}
79-
if !si.sql.isDML(argv[0]) {
77+
case !si.sql.isDML(argv[0]):
8078
return nil, 0, errors.New("this input is not sql query or sqly helper command: " + color.CyanString(statement))
81-
}
82-
83-
if si.sql.isSelect(argv[0]) || si.sql.isExplain(argv[0]) {
79+
case si.sql.isSelect(argv[0]) || si.sql.isExplain(argv[0]):
8480
table, err := si.Query(ctx, statement)
8581
if err != nil {
8682
return nil, 0, fmt.Errorf("execute query error: %v: %s", err, color.CyanString(statement))
8783
}
8884
return table, 0, nil
89-
} else if si.sql.isInsert(argv[0]) || si.sql.isUpdate(argv[0]) || si.sql.isDelete(argv[0]) {
85+
case si.sql.isInsert(argv[0]) || si.sql.isUpdate(argv[0]) || si.sql.isDelete(argv[0]):
9086
affectedRows, err := si.Repository.Exec(ctx, statement)
9187
if err != nil {
9288
return nil, 0, fmt.Errorf("execute statement error: %v: %s", err, color.CyanString(statement))
9389
}
9490
return nil, affectedRows, nil
95-
} else {
91+
default:
9692
return nil, 0, fmt.Errorf("%s\n%s: %s\n%s",
9793
color.HiRedString("*** sqly bug ***"),
9894
"please report this log", color.CyanString(statement),

0 commit comments

Comments
 (0)