{"action":"created","issue":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/1435","labels_url":"https://api.github.com/repos/querydsl/querydsl/issues/1435/labels{/name}","comments_url":"https://api.github.com/repos/querydsl/querydsl/issues/1435/comments","events_url":"https://api.github.com/repos/querydsl/querydsl/issues/1435/events","html_url":"https://github.com/querydsl/querydsl/issues/1435","id":94920354,"number":1435,"title":"BooleanBuilder OR condition generate invalid query","user":{"login":"glau2","id":1916731,"avatar_url":"https://avatars.githubusercontent.com/u/1916731?v=3","gravatar_id":"","url":"https://api.github.com/users/glau2","html_url":"https://github.com/glau2","followers_url":"https://api.github.com/users/glau2/followers","following_url":"https://api.github.com/users/glau2/following{/other_user}","gists_url":"https://api.github.com/users/glau2/gists{/gist_id}","starred_url":"https://api.github.com/users/glau2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/glau2/subscriptions","organizations_url":"https://api.github.com/users/glau2/orgs","repos_url":"https://api.github.com/users/glau2/repos","events_url":"https://api.github.com/users/glau2/events{/privacy}","received_events_url":"https://api.github.com/users/glau2/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-07-14T11:01:06Z","updated_at":"2015-07-17T18:18:08Z","closed_at":null,"body":"Hi,\r\n\r\nI have encounter the following problem:\r\n\r\nQueryDSL version: 3.6.5\r\nUsing the following libraries:\r\nquerydsl-core\r\nquerydsl-jdo\r\nquerydsl-apt\r\n\r\n\r\n\t{\r\n\t\tSystem.out.println(\"=== Test AND ===\");\r\n\t\tBooleanBuilder builder = new BooleanBuilder();\r\n\t\tfor (Predicate predicate : predicates) {\r\n\t\t\tbuilder.and(predicate);\r\n\t\t\tSystem.out.println(builder.getValue());\r\n\t\t}\r\n\t}\r\n\r\n\t{\r\n\t\tSystem.out.println(\"=== Test OR ===\");\r\n\t\tBooleanBuilder builder = new BooleanBuilder();\r\n\t\tfor (Predicate predicate : predicates) {\r\n\t\t\tbuilder.or(predicate);\r\n\t\t\tSystem.out.println(builder.getValue());\r\n\t\t}\r\n\t}\r\n\r\nThe 2 predicates that i have in the ArrayList of \"predicates\" is the following:\r\na) contains(lower(investorAccount.name),pf791798)\r\nb) contains(lower(investorAccount.ownedByUser.name),123) || contains(lower(investorAccount.ownedByUser.firstName),123)\r\n\r\nThis generate the following result:\r\n\r\n=== Test AND ===\r\ncontains(lower(investorAccount.name),pf791798) && (contains(lower(investorAccount.ownedByUser.name),123) || contains(lower(investorAccount.ownedByUser.firstName),123))\r\n=== Test OR ===\r\ncontains(lower(investorAccount.name),pf791798) || contains(lower(investorAccount.ownedByUser.name),123) || contains(lower(investorAccount.ownedByUser.firstName),123)\r\n\r\nin \"Test AND\", the query are generated correct as \"a && (b)\". However in \"Test OR\" the query is generated as \"a || b\", there are no bracket around predicate \"b\". The expected result should be \"a || (b)\"\r\n\r\nPlease could you have a look into this. And if you think my understanding is incorrect, please also let me know.\r\n\r\nPlease also let me know if you would need me to provide with more information\r\n\r\nMany thanks!!!!\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/querydsl/querydsl/issues/comments/122363877","html_url":"https://github.com/querydsl/querydsl/issues/1435#issuecomment-122363877","issue_url":"https://api.github.com/repos/querydsl/querydsl/issues/1435","id":122363877,"user":{"login":"zamrokk","id":2536368,"avatar_url":"https://avatars.githubusercontent.com/u/2536368?v=3","gravatar_id":"","url":"https://api.github.com/users/zamrokk","html_url":"https://github.com/zamrokk","followers_url":"https://api.github.com/users/zamrokk/followers","following_url":"https://api.github.com/users/zamrokk/following{/other_user}","gists_url":"https://api.github.com/users/zamrokk/gists{/gist_id}","starred_url":"https://api.github.com/users/zamrokk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zamrokk/subscriptions","organizations_url":"https://api.github.com/users/zamrokk/orgs","repos_url":"https://api.github.com/users/zamrokk/repos","events_url":"https://api.github.com/users/zamrokk/events{/privacy}","received_events_url":"https://api.github.com/users/zamrokk/received_events","type":"User","site_admin":false},"created_at":"2015-07-17T18:18:08Z","updated_at":"2015-07-17T18:18:08Z","body":"true OR true AND false => true\r\n(true OR true) AND false => false\r\n\r\ndo we agree with mathematical importance of parenthesis on \"AND\" is prior to \"OR\" operations for SQL ?\r\nand not on left evaluation processment \r\n\r\n\r\nExample to run on a DB :+1: \r\n CREATE TABLE pet (name VARCHAR(20), owner VARCHAR(20),\r\n    species VARCHAR(20));\r\n    \r\ninsert into pet values('dog','me','dog');\r\n\r\nselect * from pet\r\nwhere true or  true and false;\r\n\r\n\r\nselect * from pet\r\nwhere (true or  true) and false;\r\n\r\n\r\nselect * from pet\r\nwhere true or  (true and false);\r\n\r\n\r\n------------\r\n\r\nresult : line 1 and 3 return a result, line 2 is empty recordset\r\n\r\nThis is proving mathematical priorities on parenthesis done by the database"}}