-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rest witchcraft doesn't seem to handle sqlalchemy.dialects.mysql.LONGBLOB fields #59
Comments
For your information, the model was generated on a legacy db with sqlacodegen: |
Blob fields are not auto-mapped to file upload fields as they're not implemented yet. Though, you can try registering a file upload field or a custom serializer field that handles blobs by adding to |
Thanks @shosca for your reply. file fields are different in django since they do not store the file data in the db, only the file access and flat files are kept for storage. https://docs.djangoproject.com/en/3.0/ref/models/fields/#binaryfield MySQL LONGBLOB type is for binary data up to 2^32 bytes. They are used to store large data in the db. |
Exactly, my plan was to do a simple |
One thing that you can do for the api is to defer the content value, so something like this: class SiteContentSerializer(ModelSerizlier):
class Meta:
model = SiteContent
...
fields = ["key", "mime_type", "created_date", "updated_date"]
class SiteContentViewSet(ModelViewSet):
...
serializer_class = SiteContentSerializer
...
@action(methods=["get"], detail=True)
def value(self):
... return the blob here .... This way you will have |
@shosca for the moment I just replaced LONGBLOB by LONGTEXT(binary=True) and it seems to work. With LONGTEXT(binary=True) the ORM returns bytes instead of text. |
I have a class like this one:
the issue is with sqlalchemy.dialects.mysql.LONGBLOB fields I get this kind of tracebacks:
there seems to be an issue with LONGBLOB fields.
The text was updated successfully, but these errors were encountered: