michiya / django-pyodbc-azure

Django backend for Microsoft SQL Server and Azure SQL Database using pyodbc
https://pypi.python.org/pypi/django-pyodbc-azure
BSD 3-Clause "New" or "Revised" License
321 stars 140 forks source link

BinaryField truncated to 8000 bytes #135

Open insertjokehere opened 6 years ago

insertjokehere commented 6 years ago

Hi,

We have just encountered an issue where BinaryField fields on models may have their contents truncated to 8000 bytes when using the newest pyodbc (4.0.22). This doesn't happen with pyodbc 4.0.21.

Our reproduction looks like:

from django.db import models

class Document(models.Model):
    file = models.BinaryField(help_text="File")
>>> data = b' '*10000
>>> d = Document.objects.create(file=data)
>>> len(d.file)
10000
>>> d.refresh_from_db()
>>> len(d.file)
8000

We are using Python 3.6 (official Docker image), FreeTDS 1.0.54, django-pyodc-azure 1.11.0.0

Belval commented 6 years ago

If you still have this issue, FreeTDS by default will truncate data.

In your /etc/freetds/freetds.conf add text size = 1000000000 (Or any value you see fit).

EDIT: I just saw that it worked before. You can still try this but I doubt that you'll see much change.