Skip to content
This repository was archived by the owner on Jul 17, 2018. It is now read-only.

Field class doesn't take connection and prepared arguments #12

Open
monokrome opened this issue Oct 31, 2010 · 13 comments
Open

Field class doesn't take connection and prepared arguments #12

monokrome opened this issue Oct 31, 2010 · 13 comments

Comments

@monokrome
Copy link

Fields in new versions of django can receive a connection and prepared argument. I believe this is for multi-db. Until django-ratings accepts these variables, django will throw a DeprecationWarning using djangoratings.fields.RatingField:

DeprecationWarning: A Field class whose get_db_prep_lookup method hasn't been updated to take `connection` and `prepared` arguments.
@neithere
Copy link

neithere commented Dec 8, 2010

This warning appears at least in early snapshots of Django 1.3, not sure about 1.2.

@danawoodman
Copy link

Having same problem with SVN version of Django.

@feth
Copy link

feth commented Mar 2, 2011

I propose this : feth@3c73f2b

But as I am fairly new to django, I'm not sure if it is sufficient (ie. does not cause another problem).

@neithere
Copy link

Django 1.3 prints two warnings (and feth's patch seems to address both):

[...]/djangoratings/fields.py:316: DeprecationWarning: A Field class whose get_db_prep_save method hasn't been updated to take a `connection` argument.
  class RatingField(IntegerField):
[...]/djangoratings/fields.py:316: DeprecationWarning: A Field class whose get_db_prep_lookup method hasn't been updated to take `connection` and `prepared` arguments.
  class RatingField(IntegerField):

It would be nice to see this fixed now that Django 1.3 is out.

@monokrome
Copy link
Author

Personally, I would like to have someone that knows the internals of django's database code reassure that this fix is appropriate before committing to it. I'm pretty sure that it will cause backward compatibility issues with older Django versions.

@danawoodman
Copy link

I would assume running the regression tests Django comes with would give you your answer...

@john2x
Copy link

john2x commented Apr 24, 2011

How about using @feth's fix, but passing a default value for the prepared and/or connection parameters to preserve backward compatibility?
e.g.

def get_db_prep_save(self, value, connection=None):
def get_db_prep_lookup(self, lookup_type, value, connection=None, prepared=False):

@riggsd
Copy link

riggsd commented May 12, 2011

One method is a no-op, the second raises a NotImplementedError, nothing will break by fixing this issue; please implement @feth's trivial patch with @john2x's backwards compatibility note, or do it generically like this:

https://bitbucket.org/piquadrat/django-annoying/changeset/05460f0008ea

@andreslucena
Copy link

Kronuz's fork seems to have fixed this bug:

Kronuz@aa8375e

@shacker
Copy link

shacker commented Jun 28, 2011

Thanks andreaslucena - Yes, Kronuz's fork works.

@ashchristopher
Copy link

Has @dcramer addressed why this has not been pulled into master branch? Are there outstanding issues with this patch?

@churris43
Copy link

Any chances on getting this into the master branch? Thanks

@monokrome
Copy link
Author

The person who forked this project and fixed this didn't send a pull request to @dcramer. Thanks to whomever it was that found the fork implementing a solution. I've mentioned it to @dcramer, so we'll see if he wants to merge it or if I should get the attention of @Kronuz on sending over a pull request.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants