sqlbuilder
sqlbuilder copied to clipboard
Missing OR in WHERE
Your library is small and effective, but it only allows logical AND in the WHERE clause. Imagine you need to build a more complex query with several ANDs and ORs -- see these examples: https://www.techonthenet.com/sql/and_or.php . I took a look at your SelectBuilder class and I see for WHERE clause there is only method and(String) -- how can anyone do more complex queries, like this one?:
SELECT * FROM suppliers
WHERE (state = 'California' AND supplier_id <> 900)
OR (supplier_id = 100);
OR is not missing!
Example:
new SelectCreator().column("*").from("suppliers").where(Predicates.or(Predicates.and(Predicates.eq("state", "California"), Predicates.neq("supplier_id", 900)), Predicates.eq("supplier_id", 100)));