Skip to content

Commit

Permalink
Issue #155: Problem with files subcommand.
Browse files Browse the repository at this point in the history
Fixed regressions.
  • Loading branch information
oniony committed Nov 8, 2018
1 parent d08ccad commit c8533f2
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 12 deletions.
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ Sqlite3 libraries, their Go bindings and the Go language standard library.
Release Notes
=============

v0.7.4
------

* Fixed further regressions with the set of files returned by `files` command.

v0.7.3
------

Expand Down
2 changes: 1 addition & 1 deletion src/github.com/oniony/TMSU/storage/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func readCount(rows *sql.Rows) (uint, error) {

func collationFor(ignoreCase bool) string {
if ignoreCase {
return "COLLATE NOCASE"
return " COLLATE NOCASE"
}

return ""
Expand Down
20 changes: 10 additions & 10 deletions src/github.com/oniony/TMSU/storage/database/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ id IN (SELECT file_id
FROM file_tag
WHERE tag_id = (SELECT id
FROM tag
WHERE name ` + collation + ` = `)
WHERE name` + collation + ` = `)
builder.AppendParam(expression.Name)
builder.AppendSql(`
)
Expand All @@ -459,20 +459,20 @@ id IN (SELECT file_id
(
SELECT id, 0
FROM tag
WHERE name ` + collation + ` = `)
WHERE name` + collation + ` = `)
builder.AppendParam(expression.Name)
builder.AppendSql(`
UNION ALL
SELECT b.tag_id, b.value_id
FROM implication b, working
WHERE b.implied_tag_id = working.tag_id AND
(working.value_id = 0 OR b.implied_value_id = working.value_id)
(b.implied_value_id = working.value_id OR working.value_id = 0)
)
SELECT tag_id, value_id
FROM working
) imps
ON file_tag.tag_id = imps.tag_id AND
file_tag.value_id = imps.value_id
ON file_tag.tag_id = imps.tag_id
AND (file_tag.value_id = imps.value_id OR imps.value_id = 0)
)`)
}
}
Expand Down Expand Up @@ -500,12 +500,12 @@ id IN (SELECT file_id
FROM file_tag
WHERE tag_id = (SELECT id
FROM tag
WHERE name ` + collation + ` = `)
WHERE name` + collation + ` = `)
builder.AppendParam(expression.Tag.Name)
builder.AppendSql(`) AND
value_id = (SELECT id
FROM value
WHERE name ` + collation + ` = `)
WHERE name` + collation + ` = `)
builder.AppendParam(expression.Value.Name)
builder.AppendSql(`)
)`)
Expand All @@ -515,16 +515,16 @@ id IN (WITH RECURSIVE impft (tag_id, value_id) AS
(
SELECT t.id, v.id
FROM tag t, value v
WHERE t.name ` + collation + ` = `)
WHERE t.name` + collation + ` = `)
builder.AppendParam(expression.Tag.Name)
builder.AppendSql("AND " + valueTerm + " " + collation + " " + expression.Operator)
builder.AppendSql("AND " + valueTerm + collation + " " + expression.Operator + " ")
builder.AppendParam(expression.Value.Name)
builder.AppendSql(`
UNION ALL
SELECT b.tag_id, b.value_id
FROM implication b, impft
WHERE b.implied_tag_id = impft.tag_id AND
(impft.value_id = 0 OR b.implied_value_id = impft.value_id)
(b.implied_value_id = impft.value_id OR impft.value_id = 0)
)
SELECT file_id
Expand Down
2 changes: 1 addition & 1 deletion src/github.com/oniony/TMSU/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ import (
"github.com/oniony/TMSU/common"
)

var Version = common.ParseVersion("0.7.3")
var Version = common.ParseVersion("0.7.4")
60 changes: 60 additions & 0 deletions tests/files/implications
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,39 @@ tmsu files a >|/tmp/tmsu/stdout 2>|/tmp/tmsu/stderr
tmsu files b >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files c >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files a b c >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu files j=1 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files k >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files l >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files j=1 k l >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu files x >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files y=2 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files z >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files x y=2 z >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu files j=2 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu files not a >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not b >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not c >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu files not j >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not j=1 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not k >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not l >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu files not x >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not y >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not y=2 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu files not z >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
echo --- >>/tmp/tmsu/stdout

tmsu tags /tmp/tmsu/file1 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
tmsu tags --explicit /tmp/tmsu/file1 >>/tmp/tmsu/stdout 2>>/tmp/tmsu/stderr
Expand All @@ -57,15 +78,54 @@ diff /tmp/tmsu/stdout - <<EOF
/tmp/tmsu/file1
/tmp/tmsu/file1
/tmp/tmsu/file1
---
/tmp/tmsu/file2
/tmp/tmsu/file2
/tmp/tmsu/file2
/tmp/tmsu/file2
---
/tmp/tmsu/file3
/tmp/tmsu/file3
/tmp/tmsu/file3
/tmp/tmsu/file3
---
/tmp/tmsu/file4
---
/tmp/tmsu/file2
/tmp/tmsu/file3
/tmp/tmsu/file4
/tmp/tmsu/file2
/tmp/tmsu/file3
/tmp/tmsu/file4
/tmp/tmsu/file2
/tmp/tmsu/file3
/tmp/tmsu/file4
---
/tmp/tmsu/file1
/tmp/tmsu/file3
/tmp/tmsu/file1
/tmp/tmsu/file3
/tmp/tmsu/file4
/tmp/tmsu/file1
/tmp/tmsu/file3
/tmp/tmsu/file4
/tmp/tmsu/file1
/tmp/tmsu/file3
/tmp/tmsu/file4
---
/tmp/tmsu/file1
/tmp/tmsu/file2
/tmp/tmsu/file4
/tmp/tmsu/file1
/tmp/tmsu/file2
/tmp/tmsu/file4
/tmp/tmsu/file1
/tmp/tmsu/file2
/tmp/tmsu/file4
/tmp/tmsu/file1
/tmp/tmsu/file2
/tmp/tmsu/file4
---
/tmp/tmsu/file1: a b c
/tmp/tmsu/file1: a
/tmp/tmsu/file2: j=1 k l
Expand Down

0 comments on commit c8533f2

Please sign in to comment.