UNION query
Can you share your code and the SQL? Its hard to help without any clues you know...
 Also what database are you using? If you can't share your exact query can you give me an example that fails in a similar way?
 Please comment and I will re-open.
 I'm using postgres as my database.

Here is my code:

``` python
q1 = ASRank.select().where(ASRank.snapshot == '2014-02-04').order_by(ASRank.byte_rank).limit(10)
q2 = ASRank.select().where(ASRank.snapshot == '2014-02-04').order_by(ASRank.flow_rank).limit(10)
q = q1 | q2
```

which results in:

``` sql
SELECT "t2"."id", "t2"."snapshot_id", "t2"."asn", "t2"."byte_rank", "t2"."flow_rank", "t2"."bytes", "t2"."flows" 
FROM "asrank" AS t2 
WHERE ("t2"."snapshot_id" = 2014-02-04) ORDER BY "t2"."byte_rank" LIMIT 10 
UNION 
SELECT "t2"."id", "t2"."snapshot_id", "t2"."asn", "t2"."byte_rank", "t2"."flow_rank", "t2"."bytes", "t2"."flows" 
FROM "asrank" AS t2 
WHERE ("t2"."snapshot_id" = 2014-02-04) ORDER BY "t2"."flow_rank" LIMIT 10 ORDER BY "t1"."byte_rank"
```
 Ouch, yes I've verified the bug on both Postgresql and SQLite.
 I believe these problems should now be fixed in `master`. SQLite does not support limit/order by in the components of a compound query, but since you're using Postgres this ended up being a problem of fixing the parentheses. Your query should now be working if you pull the latest code. I'll make a new release in the next week or two.
 Oh, and thank you very much for reporting this!!
 Thanks for fixing the issue quickly.

I'm making a compound query by using the | operator but the generated query does not have correct parenthesis and results in a SQL error.

I'm using peewee version 2.5.0

I've also found a similar issue (#454) and based on the discussion it seems that the issue has been fixed in previous versions, It's strange that I'm still experiencing this problem.

Could you please look into it?

Thanks.
