Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

Commit

Permalink
simplify VersionedQuerySet 1.6 and 1.7 compatible __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
brki committed Sep 12, 2014
1 parent 2b3ee8c commit 0819559
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions versions/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

import copy
import datetime
from django import VERSION
from django.core.exceptions import SuspiciousOperation, MultipleObjectsReturned, ObjectDoesNotExist
from django.db.models.constants import LOOKUP_SEP

Expand Down Expand Up @@ -151,11 +150,8 @@ class VersionedQuerySet(QuerySet):

query_time = None

def __init__(self, model=None, query=None, using=None, hints=None):
if VERSION >= (1, 7): # Ensure the correct constructor for Django >= v1.7
super(VersionedQuerySet, self).__init__(model, query, using, hints)
else: # For Django 1.6, take the former constructor
super(VersionedQuerySet, self).__init__(model, query, using)
def __init__(self, *args, **kwargs):
super(VersionedQuerySet, self).__init__(*args, **kwargs)

This comment has been minimized.

Copy link
@jczulian

jczulian Sep 15, 2014

@brki are you sure this will work fine? I had a problem on a project recently were I was passing a dictionary to a function using kwargs. But the kwargs content was build by fetching data from another source and I was not controlling what could go inside it. Everything was fine till one day another extra key/value pair made it into the dictionary. The called function was not expecting such a parameter and hence failed.

I think that here we could have the same situation. Someone could call init providing a 'hints' parameter. And in case we run on Django 1.6 we will call the other init with this extra parameter and I think it will blow of.

But I might be wrong, did you do the test on 1.6 passing a 'hints' parameter value?

This comment has been minimized.

Copy link
@brki

brki Sep 15, 2014

Author Contributor

I'd expect it to blow up in 1.6 if a hints parameter was passed. That's the desired behaviour, no?


self.related_table_in_filter = set()
"""We will store in it all the tables we have being using in while filtering."""
Expand Down

0 comments on commit 0819559

Please sign in to comment.