async-easy-model 0.2.5__py3-none-any.whl → 0.2.6__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- async_easy_model/__init__.py +1 -1
- async_easy_model/model.py +1 -1
- async_easy_model/visualization.py +54 -4
- {async_easy_model-0.2.5.dist-info → async_easy_model-0.2.6.dist-info}/METADATA +3 -2
- async_easy_model-0.2.6.dist-info/RECORD +11 -0
- {async_easy_model-0.2.5.dist-info → async_easy_model-0.2.6.dist-info}/WHEEL +1 -1
- async_easy_model-0.2.5.dist-info/RECORD +0 -11
- {async_easy_model-0.2.5.dist-info → async_easy_model-0.2.6.dist-info/licenses}/LICENSE +0 -0
- {async_easy_model-0.2.5.dist-info → async_easy_model-0.2.6.dist-info}/top_level.txt +0 -0
async_easy_model/__init__.py
CHANGED
@@ -6,7 +6,7 @@ from typing import Optional, Any
|
|
6
6
|
from .model import EasyModel, init_db, db_config
|
7
7
|
from sqlmodel import Field, Relationship as SQLModelRelationship
|
8
8
|
|
9
|
-
__version__ = "0.2.
|
9
|
+
__version__ = "0.2.6"
|
10
10
|
__all__ = ["EasyModel", "init_db", "db_config", "Field", "Relationship", "Relation", "enable_auto_relationships", "disable_auto_relationships", "process_auto_relationships", "MigrationManager", "check_and_migrate_models", "ModelVisualizer"]
|
11
11
|
|
12
12
|
# Create a more user-friendly Relationship function
|
async_easy_model/model.py
CHANGED
@@ -1398,7 +1398,7 @@ async def init_db(migrate: bool = True, model_classes: List[Type[SQLModel]] = No
|
|
1398
1398
|
if model_classes is None:
|
1399
1399
|
model_classes = []
|
1400
1400
|
# Get all model classes by inspecting the modules
|
1401
|
-
for module_name, module in sys.modules.items():
|
1401
|
+
for module_name, module in list(sys.modules.items()):
|
1402
1402
|
if hasattr(module, "__dict__"):
|
1403
1403
|
for cls_name, cls in module.__dict__.items():
|
1404
1404
|
if isinstance(cls, type) and issubclass(cls, SQLModel) and cls != SQLModel and cls != EasyModel:
|
@@ -268,6 +268,38 @@ class ModelVisualizer:
|
|
268
268
|
"is_required": False # Changed: primary keys are not considered "required" for the diagram
|
269
269
|
}
|
270
270
|
|
271
|
+
# For EasyModel tables, make sure created_at and updated_at are included
|
272
|
+
# These fields are automatically added by EasyModel but may not be in the model definitions
|
273
|
+
is_easy_model = False
|
274
|
+
# Check class hierarchy to determine if this is an EasyModel
|
275
|
+
for base in model_class.__mro__:
|
276
|
+
if base.__name__ == "EasyModel":
|
277
|
+
is_easy_model = True
|
278
|
+
break
|
279
|
+
|
280
|
+
if is_easy_model:
|
281
|
+
# Add created_at timestamp field
|
282
|
+
fields["created_at"] = {
|
283
|
+
"name": "created_at",
|
284
|
+
"type": "datetime",
|
285
|
+
"is_primary": False,
|
286
|
+
"is_foreign_key": False,
|
287
|
+
"foreign_key_reference": None,
|
288
|
+
"is_virtual": False,
|
289
|
+
"is_required": False # Not required for user input as handled automatically
|
290
|
+
}
|
291
|
+
|
292
|
+
# Add updated_at timestamp field
|
293
|
+
fields["updated_at"] = {
|
294
|
+
"name": "updated_at",
|
295
|
+
"type": "datetime",
|
296
|
+
"is_primary": False,
|
297
|
+
"is_foreign_key": False,
|
298
|
+
"foreign_key_reference": None,
|
299
|
+
"is_virtual": False,
|
300
|
+
"is_required": False # Not required for user input as handled automatically
|
301
|
+
}
|
302
|
+
|
271
303
|
# Get standard database fields
|
272
304
|
if hasattr(model_class, "__annotations__"):
|
273
305
|
for field_name, field_type in model_class.__annotations__.items():
|
@@ -297,6 +329,9 @@ class ModelVisualizer:
|
|
297
329
|
# Check if it's a primary key
|
298
330
|
is_primary = field_name == "id"
|
299
331
|
|
332
|
+
# Check if it's an auto-generated timestamp field
|
333
|
+
is_auto_timestamp = field_name in ["created_at", "updated_at"]
|
334
|
+
|
300
335
|
# Store field information
|
301
336
|
fields[field_name] = {
|
302
337
|
"name": field_name,
|
@@ -305,7 +340,7 @@ class ModelVisualizer:
|
|
305
340
|
"is_foreign_key": False,
|
306
341
|
"foreign_key_reference": None,
|
307
342
|
"is_virtual": False,
|
308
|
-
"is_required": not is_optional and not is_primary #
|
343
|
+
"is_required": not is_optional and not is_primary and not is_auto_timestamp # Don't mark primary keys and auto timestamps as "required"
|
309
344
|
}
|
310
345
|
|
311
346
|
# Get foreign key information and update fields
|
@@ -323,7 +358,7 @@ class ModelVisualizer:
|
|
323
358
|
"is_foreign_key": True,
|
324
359
|
"foreign_key_reference": fk_target,
|
325
360
|
"is_virtual": False,
|
326
|
-
"is_required": field_name != "id" #
|
361
|
+
"is_required": field_name != "id" and field_name not in ["created_at", "updated_at"] # Don't mark auto timestamps as required
|
327
362
|
}
|
328
363
|
|
329
364
|
# Get virtual relationship fields
|
@@ -374,7 +409,14 @@ class ModelVisualizer:
|
|
374
409
|
# Get fields for this model
|
375
410
|
fields = self._get_field_information(model_class)
|
376
411
|
|
377
|
-
#
|
412
|
+
# Separate timestamp fields to place them at the bottom
|
413
|
+
timestamp_fields = {}
|
414
|
+
if "created_at" in fields:
|
415
|
+
timestamp_fields["created_at"] = fields.pop("created_at")
|
416
|
+
if "updated_at" in fields:
|
417
|
+
timestamp_fields["updated_at"] = fields.pop("updated_at")
|
418
|
+
|
419
|
+
# Add regular fields first
|
378
420
|
for field_name, field_info in fields.items():
|
379
421
|
# Format type
|
380
422
|
field_type = self._simplify_type_for_mermaid(str(field_info["type"]))
|
@@ -395,6 +437,14 @@ class ModelVisualizer:
|
|
395
437
|
# Add field
|
396
438
|
lines.append(f" {field_type} {field_name}{attrs_str}")
|
397
439
|
|
440
|
+
# Add timestamp fields at the bottom
|
441
|
+
for field_name in ["created_at", "updated_at"]:
|
442
|
+
if field_name in timestamp_fields:
|
443
|
+
field_info = timestamp_fields[field_name]
|
444
|
+
field_type = self._simplify_type_for_mermaid(str(field_info["type"]))
|
445
|
+
attrs_str = self._format_field_attributes(field_info)
|
446
|
+
lines.append(f" {field_type} {field_name}{attrs_str}")
|
447
|
+
|
398
448
|
# Close entity definition
|
399
449
|
lines.append(" }")
|
400
450
|
|
@@ -506,7 +556,7 @@ class ModelVisualizer:
|
|
506
556
|
"bool": "boolean",
|
507
557
|
"dict": "object",
|
508
558
|
"Dict": "object",
|
509
|
-
"datetime": "
|
559
|
+
"datetime": "datetime",
|
510
560
|
"date": "date",
|
511
561
|
"time": "time",
|
512
562
|
"bytes": "binary",
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.4
|
2
2
|
Name: async-easy-model
|
3
|
-
Version: 0.2.
|
3
|
+
Version: 0.2.6
|
4
4
|
Summary: A simplified SQLModel-based ORM for async database operations
|
5
5
|
Home-page: https://github.com/puntorigen/easy-model
|
6
6
|
Author: Pablo Schaffner
|
@@ -32,6 +32,7 @@ Dynamic: description
|
|
32
32
|
Dynamic: description-content-type
|
33
33
|
Dynamic: home-page
|
34
34
|
Dynamic: keywords
|
35
|
+
Dynamic: license-file
|
35
36
|
Dynamic: requires-dist
|
36
37
|
Dynamic: requires-python
|
37
38
|
Dynamic: summary
|
@@ -0,0 +1,11 @@
|
|
1
|
+
async_easy_model/__init__.py,sha256=5OzRFnNcCv5QAkDM7Gkt9jW4K1BIxXoYy_KbCZXZWnw,1739
|
2
|
+
async_easy_model/auto_relationships.py,sha256=V2LAzNi7y-keFk4C_m-byVRM-k_7nL5HEy9Ig3nEdq8,27756
|
3
|
+
async_easy_model/migrations.py,sha256=rYDGCGlruSugAmPfdIF2-uhyG6UvC_2qbF3BXJ084qI,17803
|
4
|
+
async_easy_model/model.py,sha256=f0eMcIaDOz9s01A4jpQ-T_VpCgFt67JF1puDYuhpdv4,63290
|
5
|
+
async_easy_model/relationships.py,sha256=vR5BsJpGaDcecCcNlg9-ouZfxFXFQv5kOyiXhKp_T7A,3286
|
6
|
+
async_easy_model/visualization.py,sha256=RVCdc8j3uUQe-zy3jXju_yhA13qJ8KWVbQ5fQyjyqkA,29973
|
7
|
+
async_easy_model-0.2.6.dist-info/licenses/LICENSE,sha256=uwDkl6oHbRltW7vYKNc4doJyhtwhyrSNFFlPpKATwLE,1072
|
8
|
+
async_easy_model-0.2.6.dist-info/METADATA,sha256=JRhh3mi73bMeLWAA83G3vkQl9O0avDkmasjxVVO8nFw,12888
|
9
|
+
async_easy_model-0.2.6.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
|
10
|
+
async_easy_model-0.2.6.dist-info/top_level.txt,sha256=e5_47sGmJnyxz2msfwU6C316EqmrSd9RGIYwZyWx68E,17
|
11
|
+
async_easy_model-0.2.6.dist-info/RECORD,,
|
@@ -1,11 +0,0 @@
|
|
1
|
-
async_easy_model/__init__.py,sha256=cpv45_jab9WbuemZehABoXL64VZ19R-L4-UOAbj8sls,1739
|
2
|
-
async_easy_model/auto_relationships.py,sha256=V2LAzNi7y-keFk4C_m-byVRM-k_7nL5HEy9Ig3nEdq8,27756
|
3
|
-
async_easy_model/migrations.py,sha256=rYDGCGlruSugAmPfdIF2-uhyG6UvC_2qbF3BXJ084qI,17803
|
4
|
-
async_easy_model/model.py,sha256=Vq6NTUThuEKy_CVLAb6Dy5pcDjbBr49qgamTQj5GtZ0,63284
|
5
|
-
async_easy_model/relationships.py,sha256=vR5BsJpGaDcecCcNlg9-ouZfxFXFQv5kOyiXhKp_T7A,3286
|
6
|
-
async_easy_model/visualization.py,sha256=VdW89D103sF7nnB1BG3EnGcID1HF-1TVr_U0iaOuFjA,27355
|
7
|
-
async_easy_model-0.2.5.dist-info/LICENSE,sha256=uwDkl6oHbRltW7vYKNc4doJyhtwhyrSNFFlPpKATwLE,1072
|
8
|
-
async_easy_model-0.2.5.dist-info/METADATA,sha256=G6Ol1O_uihhCchSJnf0dCHEP0G3NEl4Nd_pBJwOoKiA,12866
|
9
|
-
async_easy_model-0.2.5.dist-info/WHEEL,sha256=52BFRY2Up02UkjOa29eZOS2VxUrpPORXg1pkohGGUS8,91
|
10
|
-
async_easy_model-0.2.5.dist-info/top_level.txt,sha256=e5_47sGmJnyxz2msfwU6C316EqmrSd9RGIYwZyWx68E,17
|
11
|
-
async_easy_model-0.2.5.dist-info/RECORD,,
|
File without changes
|
File without changes
|