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

Getting django.db.utils.DataError: integer out of range with PostgreSQL database

Open hsb-tonmoy opened this issue 3 years ago • 3 comments

My model looks like this:

class Question(ModelWithFlag):
    ...

    FLAG_BOOKMARK = 10

    def bookmark_add(self, user):
        return self.set_flag(user, status=self.FLAG_BOOKMARK)

    def bookmark_remove(self, user):
        return self.remove_flag(user, status=self.FLAG_BOOKMARK)

    def bookmark_check(self, user):
        return self.is_flagged(user, status=self.FLAG_BOOKMARK)

When the bookmark_add method is run, it throws this error:

psycopg2.errors.NumericValueOutOfRange: integer out of range ... ... File "C:\Users\Tonmoy\Documents\backend\question_db\views.py", line 89, in update instance.bookmark_add(user=request.user) File "C:\Users\Tonmoy\Documents\backend\question_db\models.py", line 158, in bookmark_add return self.set_flag(user, status=self.FLAG_BOOKMARK) django.db.utils.DataError: integer out of range

I've tried changing the status field from IntegerField to BigIntegerField as per some stackoverflow answers but it didn't help.

hsb-tonmoy avatar Jan 11 '22 20:01 hsb-tonmoy

Thank you for the report.

Please check the latest bookmark and Question IDs. Maybe you have a huge number of those?

idlesign avatar Jan 12 '22 01:01 idlesign

Thank you for the report.

Please check the latest bookmark and Question IDs. Maybe you have a huge number of those?

Thanks for your reply. The siteflags_flag table is completely empty, no records at all. I have around 200 questions right now. I forgot to mention that I am using UUID as the primary key, could that be the issue?

My questions table looks like this:

image

hsb-tonmoy avatar Jan 12 '22 04:01 hsb-tonmoy

I forgot to mention that I am using UUID as the primary key, could that be the issue?

Seems so. Generic Foreign Key expects Integers to represent a tie between a bookmark and a question.

idlesign avatar Jan 12 '22 04:01 idlesign