@@ -687,7 +687,7 @@ if Code.ensure_loaded?(Postgrex) do
687687 case handle_call ( fun , length ( args ) ) do
688688 { :binary_op , op } ->
689689 [ left , right ] = args
690- [ op_to_binary ( left , sources , query ) , op | op_to_binary ( right , sources , query ) ]
690+ [ maybe_paren ( left , sources , query ) , op | maybe_paren ( right , sources , query ) ]
691691 { :fun , fun } ->
692692 [ fun , ?( , modifier , intersperse_map ( args , ", " , & expr ( & 1 , sources , query ) ) , ?) ]
693693 end
@@ -707,7 +707,7 @@ if Code.ensure_loaded?(Postgrex) do
707707 end
708708
709709 defp expr ( % Ecto.Query.Tagged { value: other , type: type } , sources , query ) do
710- [ expr ( other , sources , query ) , ?: , ?: | tagged_to_db ( type ) ]
710+ [ maybe_paren ( other , sources , query ) , ?: , ?: | tagged_to_db ( type ) ]
711711 end
712712
713713 defp expr ( nil , _sources , _query ) , do: "NULL"
@@ -749,13 +749,13 @@ if Code.ensure_loaded?(Postgrex) do
749749 interval ( 1 , interval , sources , query ) , ?) ]
750750 end
751751
752- defp op_to_binary ( { op , _ , [ _ , _ ] } = expr , sources , query ) when op in @ binary_ops ,
752+ defp maybe_paren ( { op , _ , [ _ , _ ] } = expr , sources , query ) when op in @ binary_ops ,
753753 do: paren_expr ( expr , sources , query )
754754
755- defp op_to_binary ( { :is_nil , _ , [ _ ] } = expr , sources , query ) ,
755+ defp maybe_paren ( { :is_nil , _ , [ _ ] } = expr , sources , query ) ,
756756 do: paren_expr ( expr , sources , query )
757757
758- defp op_to_binary ( expr , sources , query ) ,
758+ defp maybe_paren ( expr , sources , query ) ,
759759 do: expr ( expr , sources , query )
760760
761761 defp returning ( % { select: nil } , _sources ) ,
0 commit comments