Blob field (BinaryField) may not works
See original GitHub issueDescribe the bug Can’t query by blob fields, can’t update blob values.
To Reproduce
from tortoise import Tortoise, fields, run_async
from tortoise.models import Model
class Event(Model):
id = fields.IntField(pk=True)
bin = fields.BinaryField()
class Meta:
table = "event"
def __str__(self):
return self.name
async def run():
await Tortoise.init(db_url="sqlite://:memory:", modules={"models": ["__main__"]})
await Tortoise.generate_schemas()
event = await Event.create(bin=b'aabb')
print(Event.filter(bin=b"aabb").sql())
print(await Event.filter(id=1).update(bin=b'aacc'))
if __name__ == "__main__":
run_async(run())
Expected behavior Code just works. Actually cause error.
sql generated: SELECT “id”,“bin” FROM “event” WHERE “bin”=b’aabb’
Additional context
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Django Binary or BLOB model field - python - Stack Overflow
I have used a queryset and httpresponse to view the PDF objects in a browser (but not directly in django). Share.
Read more >Load PostGIS Layer with BLOB and use the form widget for ...
The problem is, that the binary field will not be in the layers attribute table, so the widget can not be used/activated. In...
Read more >Issue storing binary fields in 6.2.2 - Elasticsearch
My application stores long text (>32K) values in binary field. ... It will work for me in one index which is small but...
Read more >How to create a fixed-length binary field with a unique ...
the resulting field will be of type "longblob" instead of the "binary(32)" I was going for. - MySQL cannot create a unique constraint...
Read more >Documentation: 7.4: Storing Binary Data - PostgreSQL
Note: In a future release of the JDBC driver, the getBLOB() and setBLOB() methods may no longer interact with Large Objects and will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
CharField needs 2x space, and this will cause additional serialization and deserialization.
blob is part of sql standard, if native type works, why not use it?
still can not filter the blob