squirrel
squirrel copied to clipboard
[BUG] Missing brackets when using several sq.Eq inside sq.Or
Hi there, I am trying to do the exact same thing that is shown in the FAQs https://github.com/Masterminds/squirrel#faq
var metricMatcher =sq.Or{
sq.Eq{"col1": 1, "col2": 2},
sq.Eq{"col1": 3, "col2": 4}}
psql := sq.StatementBuilder.PlaceholderFormat(sq.Dollar)
q := psql.Select("name", "SUM(col1) AS totals").From(tableName).Where(metricMatcher).GroupBy("col1")
The FAQs says the query should come out as:
WHERE (col1 = 1 AND col2 = 2) OR (col1 = 3 AND col2 = 4)
But I am getting
WHERE (col1 = 1 AND col2 = 2 OR col1 = 3 AND col2 = 4)
Note that they are all being put in the same bracket. Am I passing the sq.Or into the Where incorrectly?
The documentation could be more assertive, but those two results are logically the same and should produce the same result
I don't see how they are logically the same? Is there some BEDMAS like rules applied to logical conditions? Do AND's always resolve first before OR's?