revert docs changes, pin databases, fix mypy

This commit is contained in:
collerek
2022-01-14 17:36:18 +01:00
parent bf3b36194b
commit 53a2636421
13 changed files with 61 additions and 119 deletions

View File

@ -15,23 +15,18 @@ class Book(ormar.Model):
id: int = ormar.Integer(primary_key=True)
title: str = ormar.String(max_length=200)
author: str = ormar.String(max_length=100)
genre: str = ormar.String(
max_length=100,
default="Fiction",
choices=["Fiction", "Adventure", "Historic", "Fantasy"],
)
genre: str = ormar.String(max_length=100, default='Fiction',
choices=['Fiction', 'Adventure', 'Historic', 'Fantasy'])
await Book.objects.create(title="Tom Sawyer", author="Twain, Mark", genre="Adventure")
await Book.objects.create(title="War and Peace", author="Tolstoy, Leo", genre="Fiction")
await Book.objects.create(title="Anna Karenina", author="Tolstoy, Leo", genre="Fiction")
await Book.objects.create(title='Tom Sawyer', author="Twain, Mark", genre='Adventure')
await Book.objects.create(title='War and Peace', author="Tolstoy, Leo", genre='Fiction')
await Book.objects.create(title='Anna Karenina', author="Tolstoy, Leo", genre='Fiction')
# if not exist the instance will be persisted in db
vol2 = await Book.objects.update_or_create(
title="Volume II", author="Anonymous", genre="Fiction"
)
vol2 = await Book.objects.update_or_create(title="Volume II", author='Anonymous', genre='Fiction')
assert await Book.objects.count() == 1
# if pk or pkname passed in kwargs (like id here) the object will be updated
assert await Book.objects.update_or_create(id=vol2.id, genre="Historic")
assert await Book.objects.update_or_create(id=vol2.id, genre='Historic')
assert await Book.objects.count() == 1