* fix schema with enum fields - issue #699 * fix drivers dependencies - make them optional * fix command * provide extras * add bolean field to related model * add test with select related and boolean * new test case based on issue * fix bool issue in postgres limit queries - issue #704 * fix coverage * bump version and add release info
34 lines
717 B
Python
34 lines
717 B
Python
from enum import Enum
|
|
|
|
import databases
|
|
import sqlalchemy
|
|
|
|
import ormar
|
|
from tests.settings import DATABASE_URL
|
|
|
|
database = databases.Database(DATABASE_URL, force_rollback=True)
|
|
metadata = sqlalchemy.MetaData()
|
|
|
|
|
|
class MyEnum(Enum):
|
|
SMALL = 1
|
|
BIG = 2
|
|
|
|
|
|
class EnumExample(ormar.Model):
|
|
class Meta:
|
|
tablename = "enum_example"
|
|
metadata = metadata
|
|
database = database
|
|
|
|
id: int = ormar.Integer(primary_key=True)
|
|
size: MyEnum = ormar.Enum(enum_class=MyEnum, default=MyEnum.SMALL)
|
|
|
|
|
|
def test_proper_schema():
|
|
schema = EnumExample.schema_json()
|
|
assert (
|
|
'{"MyEnum": {"title": "MyEnum", "description": "An enumeration.", '
|
|
'"enum": [1, 2]}}' in schema
|
|
)
|