django-ratings icon indicating copy to clipboard operation
django-ratings copied to clipboard

Field class doesn't take connection and prepared arguments

Open monokrome opened this issue 15 years ago • 13 comments
trafficstars

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.

monokrome avatar Oct 31 '10 19:10 monokrome

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

neithere avatar Dec 08 '10 21:12 neithere

Having same problem with SVN version of Django.

danawoodman avatar Jan 10 '11 23:01 danawoodman

I propose this : https://github.com/feth/django-ratings/commit/3c73f2b9e860f778bed348ed8748ccc1826285b5

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

feth avatar Mar 02 '11 17:03 feth

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.

neithere avatar Mar 26 '11 06:03 neithere

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.

monokrome avatar Mar 26 '11 09:03 monokrome

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

danawoodman avatar Mar 26 '11 16:03 danawoodman

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):

john2x avatar Apr 24 '11 04:04 john2x

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

riggsd avatar May 12 '11 16:05 riggsd

Kronuz's fork seems to have fixed this bug:

https://github.com/Kronuz/django-ratings/commit/aa8375e95279b493c734f2794bc65405cb96e5cb

andreslucena avatar Jun 09 '11 11:06 andreslucena

Thanks andreaslucena - Yes, Kronuz's fork works.

shacker avatar Jun 28 '11 21:06 shacker

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

ashchristopher avatar Aug 17 '11 19:08 ashchristopher

Any chances on getting this into the master branch? Thanks

churris43 avatar Nov 10 '11 04:11 churris43

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.

monokrome avatar Nov 10 '11 22:11 monokrome