WIP super dirty - change to descriptors and different tries
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
import asyncio
|
||||
import datetime
|
||||
import os
|
||||
import uuid
|
||||
from typing import List
|
||||
|
||||
@ -37,7 +38,23 @@ class LargeBinarySample(ormar.Model):
|
||||
database = database
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
test_binary = ormar.LargeBinary(max_length=100000, choices=[blob, blob2])
|
||||
test_binary: bytes = ormar.LargeBinary(max_length=100000, choices=[blob, blob2])
|
||||
|
||||
|
||||
blob3 = os.urandom(64)
|
||||
blob4 = os.urandom(100)
|
||||
|
||||
|
||||
class LargeBinaryStr(ormar.Model):
|
||||
class Meta:
|
||||
tablename = "my_str_blobs"
|
||||
metadata = metadata
|
||||
database = database
|
||||
|
||||
id: int = ormar.Integer(primary_key=True)
|
||||
test_binary: str = ormar.LargeBinary(
|
||||
max_length=100000, choices=[blob3, blob4], represent_as_base64=True
|
||||
)
|
||||
|
||||
|
||||
class UUIDSample(ormar.Model):
|
||||
@ -171,6 +188,19 @@ async def test_binary_column():
|
||||
assert items[1].test_binary == blob2
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_binary_str_column():
|
||||
async with database:
|
||||
async with database.transaction(force_rollback=True):
|
||||
await LargeBinaryStr.objects.create(test_binary=blob3)
|
||||
await LargeBinaryStr.objects.create(test_binary=blob4)
|
||||
|
||||
items = await LargeBinaryStr.objects.all()
|
||||
assert len(items) == 2
|
||||
assert items[0].test_binary == blob3
|
||||
assert items[1].test_binary == blob4
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_uuid_column():
|
||||
async with database:
|
||||
|
||||
Reference in New Issue
Block a user