add large binary field, tests and docs

This commit is contained in:
collerek
2021-04-28 17:04:29 +02:00
parent 638af9ad4c
commit 11ed5fd322
13 changed files with 148 additions and 14 deletions

View File

@ -127,6 +127,17 @@ You can use either `length` and `precision` parameters or `max_digits` and `deci
* Sqlalchemy column: `sqlalchemy.JSON`
* Type (used for pydantic): `pydantic.Json`
### LargeBinary
`LargeBinary(max_length)` has a required `max_length` parameter.
* Sqlalchemy column: `sqlalchemy.LargeBinary`
* Type (used for pydantic): `bytes`
LargeBinary length is used in some backend (i.e. mysql) to determine the size of the field,
in other backends it's simply ignored yet in ormar it's always required. It should be max
size of the file/bytes in bytes.
### UUID
`UUID(uuid_format: str = 'hex')` has no required parameters.

View File

@ -451,6 +451,16 @@ async def aggregations():
# to read more about aggregated functions
# visit: https://collerek.github.io/ormar/queries/aggregations/
async def with_connect(function):
# note that for any other backend than sqlite you actually need to
# connect to the database to perform db operations
async with database:
await function()
# note that if you use framework like `fastapi` you shouldn't connect
# in your endpoints but have a global connection pool
# check https://collerek.github.io/ormar/fastapi/ and section with db connection
# gather and execute all functions
# note - normally import should be at the beginning of the file
@ -462,7 +472,7 @@ for func in [create, read, update, delete, joins,
filter_and_sort, subset_of_columns,
pagination, aggregations]:
print(f"Executing: {func.__name__}")
asyncio.run(func())
asyncio.run(with_connect(func))
# drop the database tables
metadata.drop_all(engine)
@ -521,6 +531,7 @@ Available Model Fields (with required args - optional ones in docs):
* `BigInteger()`
* `Decimal(scale, precision)`
* `UUID()`
* `LargeBinary(max_length)`
* `EnumField` - by passing `choices` to any other Field type
* `EncryptedString` - by passing `encrypt_secret` and `encrypt_backend`
* `ForeignKey(to)`

View File

@ -1,3 +1,14 @@
# 0.10.6
## ✨ Features
* Add `LargeBinary(max_length)` field type [#166](https://github.com/collerek/ormar/issues/166)
## 💬 Other
* Add connecting the database in quickstart in readme [#180](https://github.com/collerek/ormar/issues/180)
# 0.10.5
## 🐛 Fixes