question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Blob field (BinaryField) may not works

See original GitHub issue

Describe 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:open
  • Created 3 years ago
  • Reactions:2
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
fy0commented, Nov 2, 2020

Why not use UUIDField or CharField directly?

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?

0reactions
purplegrapeZzcommented, May 3, 2022

still can not filter the blob

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found