From c8533f23548ee64aa461161016889cbc609321b4 Mon Sep 17 00:00:00 2001 From: Paul Ruane Date: Thu, 8 Nov 2018 02:25:20 +0000 Subject: [PATCH] Issue #155: Problem with files subcommand. Fixed regressions. --- README.md | 5 ++ .../oniony/TMSU/storage/database/database.go | 2 +- .../oniony/TMSU/storage/database/file.go | 20 +++---- src/github.com/oniony/TMSU/version/version.go | 2 +- tests/files/implications | 60 +++++++++++++++++++ 5 files changed, 77 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 96333382..259f8d24 100644 --- a/README.md +++ b/README.md @@ -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 ------ diff --git a/src/github.com/oniony/TMSU/storage/database/database.go b/src/github.com/oniony/TMSU/storage/database/database.go index 8be671b5..362b4f19 100644 --- a/src/github.com/oniony/TMSU/storage/database/database.go +++ b/src/github.com/oniony/TMSU/storage/database/database.go @@ -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 "" diff --git a/src/github.com/oniony/TMSU/storage/database/file.go b/src/github.com/oniony/TMSU/storage/database/file.go index 00fc0b75..28e498fc 100644 --- a/src/github.com/oniony/TMSU/storage/database/file.go +++ b/src/github.com/oniony/TMSU/storage/database/file.go @@ -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(` ) @@ -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) )`) } } @@ -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(`) )`) @@ -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 diff --git a/src/github.com/oniony/TMSU/version/version.go b/src/github.com/oniony/TMSU/version/version.go index 48b877cc..041d4ee5 100644 --- a/src/github.com/oniony/TMSU/version/version.go +++ b/src/github.com/oniony/TMSU/version/version.go @@ -19,4 +19,4 @@ import ( "github.com/oniony/TMSU/common" ) -var Version = common.ParseVersion("0.7.3") +var Version = common.ParseVersion("0.7.4") diff --git a/tests/files/implications b/tests/files/implications index e833c1ec..050b0e96 100755 --- a/tests/files/implications +++ b/tests/files/implications @@ -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 @@ -57,15 +78,54 @@ diff /tmp/tmsu/stdout - <