Issue: TypeError: unhashable type: 'SQL'
Author: several27
State: closed
Created: 2018-02-02 00:32:51

Hi all, I'm trying to run the examples from the docs on sqlite database: http://docs.peewee-orm.com/en/latest/peewee/querying.html?highlight=modulo#adding-user-defined-operators . Creating an exact modulo operator as shown there with just those few lines: 

```
from peewee import *
from peewee import Expression # the building block for expressions

def mod(lhs, rhs):
    return Expression(lhs, SQL('%'), rhs)

# Users with even ids.
User.select().where(mod(User.id, 2) == 0)
```

But I'm getting the following error: 

```
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 3240, in __iter__
    return iter(self.execute())
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 3233, in execute
    self._qr = ResultWrapper(model_class, self._execute(), query_meta)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 2911, in _execute
    sql, params = self.sql()
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 3201, in sql
    return self.compiler().generate_select(self)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 2026, in generate_select
    return self.build_query(clauses, alias_map)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1912, in build_query
    return self.parse_node(Clause(*clauses), alias_map)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1865, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1831, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1757, in _parse_clause
    node.nodes, alias_map, conv, node.glue)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1890, in parse_node_list
    node_sql, node_params = self.parse_node(node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1865, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1831, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1727, in _parse_expression
    lhs, lparams = self.parse_node(node.lhs, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1865, in parse_node
    sql, params, unknown = self._parse(node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1831, in _parse
    sql, params = self._parse_map[node_type](node, alias_map, conv)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1732, in _parse_expression
    sql = template % (lhs, self.get_op(node.op), rhs)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/site-packages/peewee.py", line 1716, in get_op
    return self._op_map[q]
TypeError: unhashable type: 'SQL'
```

Am I doing something wrong (importing the wrong module) or is it a bug? 

I've fixed the docs, the correct way in 3.x is:

```python
def mod(lhs, rhs):
    return Expression(lhs, '%', rhs)  # No need for "SQL()" around '%'.
```