1{
2 lib,
3 aiomysql,
4 aiopg,
5 aiosqlite,
6 asyncpg,
7 buildPythonPackage,
8 cryptography,
9 databases,
10 fastapi,
11 fetchFromGitHub,
12 httpx,
13 importlib-metadata,
14 mysqlclient,
15 nest-asyncio,
16 orjson,
17 poetry-core,
18 psycopg2,
19 pydantic,
20 pymysql,
21 pytest-asyncio,
22 pytestCheckHook,
23 pythonOlder,
24 pythonRelaxDepsHook,
25 sqlalchemy,
26 typing-extensions,
27}:
28
29buildPythonPackage rec {
30 pname = "ormar";
31 version = "0.12.2";
32 format = "pyproject";
33
34 disabled = pythonOlder "3.7";
35
36 src = fetchFromGitHub {
37 owner = "collerek";
38 repo = pname;
39 rev = "refs/tags/${version}";
40 hash = "sha256-Yd5ex0bcy61zq5Sn2dKeb98s/CMxUWnyGx6jFWQ3RUs=";
41 };
42
43 pythonRelaxDeps = [
44 "databases"
45 "pydantic"
46 "SQLAlchemy"
47 ];
48
49 nativeBuildInputs = [
50 poetry-core
51 pythonRelaxDepsHook
52 ];
53
54 propagatedBuildInputs =
55 [
56 databases
57 psycopg2
58 pydantic
59 sqlalchemy
60 psycopg2
61 ]
62 ++ lib.optionals (pythonOlder "3.8") [
63 typing-extensions
64 importlib-metadata
65 ];
66
67 passthru.optional-dependencies = {
68 postgresql = [ asyncpg ];
69 postgres = [ asyncpg ];
70 aiopg = [ aiopg ];
71 mysql = [ aiomysql ];
72 sqlite = [ aiosqlite ];
73 orjson = [ orjson ];
74 crypto = [ cryptography ];
75 all = [
76 aiomysql
77 aiopg
78 aiosqlite
79 asyncpg
80 cryptography
81 mysqlclient
82 orjson
83 pymysql
84 ];
85 };
86
87 nativeCheckInputs = [ pytestCheckHook ];
88
89 checkInputs = [
90 fastapi
91 httpx
92 nest-asyncio
93 pytest-asyncio
94 ] ++ passthru.optional-dependencies.all;
95
96 disabledTestPaths = [ "benchmarks/test_benchmark_*.py" ];
97
98 disabledTests = [
99 # TypeError: Object of type bytes is not JSON serializable
100 "test_bulk_operations_with_json"
101 "test_all_endpoints"
102 # Tests require a database
103 "test_model_multiple_instances_of_same_table_in_schema"
104 "test_load_all_multiple_instances_of_same_table_in_schema"
105 "test_filter_groups_with_instances_of_same_table_in_schema"
106 "test_model_multiple_instances_of_same_table_in_schema"
107 "test_right_tables_join"
108 "test_multiple_reverse_related_objects"
109 "test_related_with_defaults"
110 "test_model_creation"
111 "test_default_orders_is_applied_on_related_two_fields"
112 "test_default_orders_is_applied_from_relation"
113 "test_sum_method"
114 "test_count_method "
115 "test_queryset_methods"
116 "test_queryset_update"
117 "test_selecting_subset"
118 "test_selecting_subset_of_through_model"
119 "test_simple_queryset_values"
120 "test_queryset_values_nested_relation"
121 "test_queryset_simple_values_list"
122 "test_queryset_nested_relation_values_list"
123 "test_queryset_nested_relation_subset_of_fields_values_list"
124 "test_m2m_values"
125 "test_nested_m2m"
126 "test_nested_flatten_and_exception"
127 "test_queryset_values_multiple_select_related"
128 "test_querysetproxy_values"
129 "test_querysetproxy_values_list"
130 "test_reverse_many_to_many_cascade"
131 "test_not_saved_raises_error"
132 "test_not_existing_raises_error"
133 "test_assigning_related_objects"
134 "test_quering_of_the_m2m_models"
135 "test_removal_of_the_relations"
136 "test_selecting_related"
137 "test_adding_unsaved_related"
138 "test_removing_unsaved_related"
139 "test_quering_of_related_model_works_but_no_result"
140 ];
141
142 pythonImportsCheck = [ "ormar" ];
143
144 meta = with lib; {
145 description = "Async ORM with fastapi in mind and pydantic validation";
146 homepage = "https://github.com/collerek/ormar";
147 changelog = "https://github.com/collerek/ormar/releases/tag/${version}";
148 license = licenses.mit;
149 maintainers = with maintainers; [ andreasfelix ];
150 };
151}