Repository: kayak/pypika (python)

Issue:
Union queries with `+` seems to be broken when used for more than 2 queries
**Example**
```
from pypika import Tables, Query
a,b,c = Tables('a', 'b', 'c')
qa=Query.from_(a).select(a.a, 'name')
qb=Query.from_(b).select(b.b, 'name')
qc=Query.from_(c).select(c.c, 'name')

qa+qb
str(qa+qb)  # 1)
qa+qb+qc
str(qa+qb+qc)  # 2)
```

this used to output
1) `'(SELECT "a","name" FROM "a") UNION (SELECT "b","name" FROM "b")'`
2) `'((SELECT "a","name" FROM "a") UNION (SELECT "b","name" FROM "b")) UNION (SELECT "c","name" FROM "c")'`

**Issue**
Now, it out puts for 
1) still the same but for 
2) `'(SELECT "a","name" FROM "a") UNION (SELECT "b","name" FROM "b")+SELECT "c","name" FROM "c"'`

`qa+qb` is a `UnionQuery`, but `qa+qb+qc` is an `ArithmeticExpression`

if my bisect was correct, this was introduced in commit `3e850da1fdca72e0766a4e7b5bceceb88a97acaa`

**work around**
using `.union()` instead of the `+` sign still works fine


Pull request description:
fix #111: concatente multiple unions through arithmetic symbols

Patch:
diff --git a/pypika/queries.py b/pypika/queries.py
index 2883663..00c620e 100644
--- a/pypika/queries.py
+++ b/pypika/queries.py
@@ -212,6 +212,12 @@ class _UnionQuery(Selectable, Term):
     def union_all(self, other):
         self._unions.append((UnionType.all, other))
 
+    def __add__(self, other):
+        return self.union(other)
+
+    def __mul__(self, other):
+        return self.union_all(other)
+
     def __str__(self):
         return self.get_sql()
 


Test patch:
diff --git a/pypika/tests/test_joins.py b/pypika/tests/test_joins.py
index 9cde63c..3992331 100644
--- a/pypika/tests/test_joins.py
+++ b/pypika/tests/test_joins.py
@@ -355,6 +355,28 @@ class UnionTests(unittest.TestCase):
         self.assertEqual('(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', str(query1 + query2))
         self.assertEqual('(SELECT "foo" FROM "abc") UNION (SELECT "bar" FROM "efg")', str(query1.union(query2)))
 
+    def test_union_multiple(self):
+        table3, table4 = Tables('hij', 'lmn')
+        query1 = Query.from_(self.table1).select(self.table1.foo)
+        query2 = Query.from_(self.table2).select(self.table2.bar)
+        query3 = Query.from_(table3).select(table3.baz)
+        query4 = Query.from_(table4).select(table4.faz)
+
+        self.assertEqual(
+            '(SELECT "foo" FROM "abc") UNION '
+            '(SELECT "bar" FROM "efg") UNION '
+            '(SELECT "baz" FROM "hij") UNION '
+            '(SELECT "faz" FROM "lmn")',
+            str(query1 + query2 + query3 + query4)
+        )
+        self.assertEqual(
+            '(SELECT "foo" FROM "abc") UNION '
+            '(SELECT "bar" FROM "efg") UNION '
+            '(SELECT "baz" FROM "hij") UNION '
+            '(SELECT "faz" FROM "lmn")',
+            str(query1.union(query2).union(query3).union(query4))
+        )
+
     def test_union_all(self):
         query1 = Query.from_(self.table1).select(self.table1.foo)
         query2 = Query.from_(self.table2).select(self.table2.bar)
@@ -427,4 +449,4 @@ class UnionTests(unittest.TestCase):
         q = Query.from_(hij).select(fn.Avg(hij.t))
 
         self.assertEqual('SELECT AVG("sq0"."t") FROM ((SELECT "t" FROM "abc") UNION (SELECT "t" FROM "efg")) "sq0"',
-                         str(q))
\ No newline at end of file
+                         str(q))