http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=10542
--- Comment #16 from David Cook <[email protected]> --- So I have 5 records: "A", "B", "C", "D", and "E". [As of this writing, all of them return 1 record except D which returns all 5...should've picked a different letter. Oh well.] Every one of them has the value "test" in them as well. -- TEST: @and "a" "b" = No records "a" and "b" -- TEST: @and @or "a" "b" "c" = No records [no] ("a" and "b") or "c" ["a" and "b" = 0. "c" = 1.] [?] "a" and ("b" or "c") ["a" and "b" = 0. "a" and "c" = 0.] [?] ("a" or "b") and "c" ["a" and "c" = 0. "b" and "c" = 0.] [no] "a" or ("b" and "c") ["a" = 1. "b" and "c" = 0.] -- TEST: @and @or "a" "b" "test" = 2 records ("A","B") [?] ("a") or ("b" and "test") ["a" = 1. "b" and "test" = 1. Grand total of 2. [?] ("a" or "b") and "test" ["a" and "test" = 1. "b" and "test" = 1. Grand total of 2. [no] "a" and ("b" or "test") ["a" and "b" = 0. "a" and "test" = 5.] [no] ("a" and "b") or "test" ["a" and "b" = 0. "test" = 5.] -- TEST: @and @or "test" "B" "C" = 1 record ("C") [no] ("test" and "B") or "C" ["test and "B" = 1. "C" = 1. Grand total 2 records of "B" and "C"] [no] "test" and ("B" or "C") ["test" and "B" = 1. "test" and "C" = 1. Grand total 2 records of "B" and "C"] [YES] ("test" or "B") and "C" ["test" and "C" = 1. "B" and "C" = 0.] [no] "test" or ("B" and "C") ["test" = 5. "B" and "C" = 0] -- So...it looks like queries are expanded from the inside out... @and @or "test" "B" "C" ("test" or "b") and "C" Let's do some more tests to double-check this... -- TEST: @not "test" "b" = 4 records ("A","C","D",E") "test" and not "b" -- TEST: @not @or "b" "test" "b" = 4 records ("A","C","D","E") ("b" or "test") and not "b" -- TEST: @not @or "b" "c" "b" = 1 record ("C") ("b" or "c") and not "b" -- TEST: @not @or @or "b" "c" "a" "b" = 2 records ("A","C") (("b" or "c") or "a") and not "b" -- TEST: @not @or @or "b" "c" "a" "e" = 3 records ("A","B","C") (("b" or "c") or "a") and not "e" -- TEST: @not @or @and "b" "c" "a" "e" = 1 record ("A") (("b" and "c") or "a") and not "e" ["b" and "c" = 0. "a" = 1". Not "E"..."A" isn't "E" so it goes through. -- TEST: @not @or @and "b" "c" "a" "a" (("b" and "c") or "a") and not "a" ["b" and "c" = 0. "a" = 1". Not "A"..."A" is "A" so it doesn't make it to the result set.] -- TEST: @or @not @or "b" "c" "c" "e" = 2 records ("B","E") (("b" or "c") and not "c") or "e" ["b" = 1. "c" = 1. But not C...so only B. Or "E". Ergo, "B","E" returned) -- TEST: @or @not "test" "c" "e" = 4 records ("A","B","D","E") ("test" and not "C") or "e" -- TEST: @or @not "test" "c" "c" = 4 records ("A","B","C","D","E") ("test" and not "C") or "C" -- TEST: @not "test" @or "c" "e" = 3 records ("A","B","D") ("test") and not ("c" or "e") -- So...it appears that the Zebra parser takes the right-most operator and puts it after the first operand it encounters to its right... So...let's look at my query again... @not @or @or @or @attr 1=1016 @attr 5=1 @attr 4=6 "e" @attr 9=75 @attr 2=102 @attr 5=1 @attr 4=6 "e" @attr 9=20 @attr 2=102 @attr 5=1 @attr 4=6 "e" @attr 9=34 @attr 2=102 @attr 5=1 @attr 4=6 "e" @attr 1=9011 1 This would become (((@attr 1=1016 @attr 5=1 @attr 4=6 "e" @or @attr 9=75 @attr 2=102 @attr 5=1 @attr 4=6 "e") @or @attr 9=20 @attr 2=102 @attr 5=1 @attr 4=6 "e") @or @attr 9=34 @attr 2=102 @attr 5=1 @attr 4=6 "e") @not @attr 1=9011 1 That should be OK... That means that it will perform 5 sub-queries...4 of them will have OR between them...which produces the result set we want... Then the final sub-query returns a result set for records we don't want, and it acts as a filter to make sure that no suppressed records get through. Voila! -- You are receiving this mail because: You are watching all bug changes. _______________________________________________ Koha-bugs mailing list [email protected] http://lists.koha-community.org/cgi-bin/mailman/listinfo/koha-bugs website : http://www.koha-community.org/ git : http://git.koha-community.org/ bugs : http://bugs.koha-community.org/
