Skip to content

Commit

Permalink
Merge pull request #1202 from Necoro/fix_get_None
Browse files Browse the repository at this point in the history
Make Model.get(val = None) work the same as Model.select().where(Model.val == None)
  • Loading branch information
coleifer committed Mar 5, 2017
2 parents 5148b6a + 4495d5e commit 113ef55
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion peewee.py
Expand Up @@ -2822,11 +2822,13 @@ def convert_dict_to_node(self, qdict):
if '__' in key and key.rsplit('__', 1)[1] in DJANGO_MAP:
key, op = key.rsplit('__', 1)
op = DJANGO_MAP[op]
elif value is None:
op = OP.IS
else:
op = OP.EQ
for piece in key.split('__'):
model_attr = getattr(curr, piece)
if isinstance(model_attr, relationship):
if value is not None and isinstance(model_attr, relationship):
curr = model_attr.rel_model
joins.append(model_attr)
accum.append(Expression(model_attr, op, value))
Expand Down

0 comments on commit 113ef55

Please sign in to comment.