A way to add to where clauses without brackets?

When I add operations to a select’s where, the prior existing value is grouped together with brackets:

>>> import sql, sql.operators
>>> table = sql.Table("Test")
>>> select = table.select(table.a)
>>> select.where = sql.operators.Equal(table.b, table.c)
>>> select.where |= sql.operators.Equal(table.d, table.e)
>>> select.where |= sql.operators.Equal(table.f, table.g)
>>> str(select)
'SELECT "a"."a" FROM "Test" AS "a" WHERE ((("a"."b" = "a"."c") OR ("a"."d" = "a"."e")) OR ("a"."f" = "a"."g"))'

is there a way to get something similar to:

'SELECT "a"."a" FROM "Test" AS "a" WHERE "a"."b" = "a"."c" OR "a"."d" = "a"."e" OR "a"."f" = "a"."g"'

instead? i.e. without the brackets (the ones that control operator precedence at least).
This is on SQLite.

You can add more than 2 expression to sql.operators.Or but we will always put parenthesis around operators because the operator does not know what is next to it.

1 Like