Union broken in MySQL due to parentheses problem
Yeah, this query is failing on MySQL but works OK for Sqlite or Postgres.

For sqlite, we have a rule to never put parentheses around the left- or right-hand side.

For postgres, we always do, since postgres handles it correctly.

For mysql, we have a rule to not put parentheses if the left- or right-hand side is itself a compound query. It appears this is overly-simplistic. I honestly don't understand how mysql decides when to handle parentheses vs choke/throw an error. I think I've hacked in a fix for now by checking if the compound query is inside an expression or function-call, and in that case to avoid using parens. If there's a better rule I can apply, I'd be eager to implement it. It appears that this particular sql parsing bug has existed in MySQL for over 12 years now:

https://bugs.mysql.com/bug.php?id=25734

It appears to be fixed in 8.0, but I'm guessing you're either on 5.x or using MariaDB.

My suggestion is that although this is somewhat fixed, to try and re-work your query. MariaDB thought they fixed it for 10.4: https://jira.mariadb.org/browse/MDEV-11953

But they missed some scenarios, including using compound select queries inside an IN expression (e.g.). I've opened a ticket, so we'll see what happens: https://jira.mariadb.org/browse/MDEV-20606
I believe that https://github.com/coleifer/peewee/commit/36bd887ac07647c60dfebe610b34efabec675706 broke a weird query that we have. I believe that the outer level or parens are not being detected.

Work in 3.6.4
Broken in 3.10.0

Repro case:
```python
import logging

from peewee import *
from playhouse.db_url import connect

db = connect("mysql://user:password@localhost:3307/testdb")

class Person(Model):
  name = CharField()

  class Meta:
    database = db # This model uses the "people.db" database.


if __name__ == '__main__':
  logging.basicConfig(level=logging.DEBUG)
  db.create_tables([Person])
  for person in (Person
                 .select()
                 .where(Person.id << (Person
                                      .select(Person.name)
                                      .where(Person.name == "bill")
                                      .union_all(Person
                                                 .select(Person.name)
                                                 .where(Person.name == "frank")
                                                )
                                     )
                       )
                ):
    print(person.name)
```