Skip to content

Commit 276abf3

Browse files
committed
Revert "internal/db: #9 add case insensitive search"
This reverts commit eeb43df. While this change did successfully allow case insensitive searching, it also made regex matching of upper case letters not possible such as '^[A-Z]+$'. This would have defeated the purpose of having regex in the first place so only an implementation of case insensitive searching that doesn't sacrifice regex functionality should be added.
1 parent eeb43df commit 276abf3

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

internal/db.go

+10-10
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func dbInit(dbPath string) {
6666
}
6767
// sqlite regex function
6868
regex := func(re, s string) (bool, error) {
69-
b, e := regexp.MatchString(fmt.Sprintf(`(?i)%v`, re), s)
69+
b, e := regexp.MatchString(re, s)
7070
return b, e
7171
}
7272

@@ -247,10 +247,10 @@ func (cmd Command) commandGet() ([]Query, error) {
247247
SELECT * FROM (
248248
SELECT DISTINCT ON ("command") command, "uuid", "created"
249249
FROM commands
250-
WHERE "user_id" = '%v'
251-
AND "path" = '%v'
252-
AND "system_name" = '%v'
253-
AND "command" ~* '%v'
250+
WHERE "user_id" = '%v'
251+
AND "path" = '%v'
252+
AND "system_name" = '%v'
253+
AND "command" ~ '%v'
254254
) c
255255
ORDER BY "created" DESC limit '%v';`, cmd.User.ID, cmd.Path, cmd.SystemName, cmd.Query, cmd.Limit)
256256

@@ -261,7 +261,7 @@ func (cmd Command) commandGet() ([]Query, error) {
261261
FROM commands
262262
WHERE "user_id" = '%v'
263263
AND "path" = '%v'
264-
AND "command" ~* '%v'
264+
AND "command" ~ '%v'
265265
) c
266266
ORDER BY "created" DESC limit '%v';`, cmd.User.ID, cmd.Path, cmd.Query, cmd.Limit)
267267

@@ -271,7 +271,7 @@ func (cmd Command) commandGet() ([]Query, error) {
271271
FROM commands
272272
WHERE "user_id" = '%v'
273273
AND "system_name" = '%v'
274-
AND "command" ~* '%v'
274+
AND "command" ~ '%v'
275275
ORDER BY "created" DESC limit '%v';`, cmd.User.ID, cmd.SystemName, cmd.Query, cmd.Limit)
276276

277277
} else if cmd.Path != "" && cmd.Query != "" {
@@ -280,7 +280,7 @@ func (cmd Command) commandGet() ([]Query, error) {
280280
FROM commands
281281
WHERE "user_id" = '%v'
282282
AND "path" = '%v'
283-
AND "command" ~* '%v'
283+
AND "command" ~ '%v'
284284
ORDER BY "created" DESC limit '%v';`, cmd.User.ID, cmd.Path, cmd.Query, cmd.Limit)
285285

286286
} else if cmd.SystemName != "" && cmd.Unique {
@@ -309,7 +309,7 @@ func (cmd Command) commandGet() ([]Query, error) {
309309
SELECT DISTINCT ON ("command") command, "uuid", "created"
310310
FROM commands
311311
WHERE "user_id" = '%v'
312-
AND "command" ~* '%v'
312+
AND "command" ~ '%v'
313313
) c
314314
ORDER BY "created" DESC limit '%v';`, cmd.User.ID, cmd.Query, cmd.Limit)
315315

@@ -318,7 +318,7 @@ func (cmd Command) commandGet() ([]Query, error) {
318318
SELECT "command", "uuid", "created"
319319
FROM commands
320320
WHERE "user_id" = '%v'
321-
AND "command" ~* '%v'
321+
AND "command" ~ '%v'
322322
ORDER BY "created" DESC limit '%v';`, cmd.User.ID, cmd.Query, cmd.Limit)
323323

324324
} else {

0 commit comments

Comments
 (0)