sqlobjects 1.0.2__tar.gz → 1.0.3__tar.gz
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.
- {sqlobjects-1.0.2/sqlobjects.egg-info → sqlobjects-1.0.3}/PKG-INFO +1 -1
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/pyproject.toml +1 -1
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/mixins.py +6 -13
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/model.py +43 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3/sqlobjects.egg-info}/PKG-INFO +1 -1
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/LICENSE +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/README.md +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/setup.cfg +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/cascade.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/database/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/database/config.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/database/manager.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/exceptions.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/aggregate.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/base.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/function.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/mixins.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/scalar.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/subquery.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/expressions/terminal.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/core.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/functions.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/proxies.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/relations/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/relations/descriptors.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/relations/managers.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/relations/proxies.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/relations/utils.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/shortcuts.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/types/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/types/base.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/types/comparators.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/types/registry.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/fields/utils.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/metadata.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/objects/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/objects/bulk.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/objects/core.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/queries/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/queries/builder.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/queries/executor.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/queryset.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/session.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/signals.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/utils/__init__.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/utils/inspect.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/utils/naming.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/utils/pattern.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects/validators.py +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects.egg-info/SOURCES.txt +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects.egg-info/dependency_links.txt +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects.egg-info/requires.txt +0 -0
- {sqlobjects-1.0.2 → sqlobjects-1.0.3}/sqlobjects.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlobjects
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Django-style async ORM library based on SQLAlchemy with chainable queries, Q objects, and relationship loading
|
|
5
5
|
Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
6
6
|
Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
@@ -392,19 +392,7 @@ class DataConversionMixin(DeferredLoadingMixin):
|
|
|
392
392
|
all_fields = set(cls._get_field_names())
|
|
393
393
|
filtered_data = {k: v for k, v in data.items() if k in all_fields}
|
|
394
394
|
|
|
395
|
-
|
|
396
|
-
for col in table.columns: # noqa
|
|
397
|
-
if col.name not in filtered_data:
|
|
398
|
-
field_attr = getattr(cls, col.name, None)
|
|
399
|
-
if field_attr is not None and hasattr(field_attr, "get_default_factory"):
|
|
400
|
-
factory = field_attr.get_default_factory()
|
|
401
|
-
if factory and callable(factory):
|
|
402
|
-
filtered_data[col.name] = factory()
|
|
403
|
-
continue
|
|
404
|
-
|
|
405
|
-
if col.default is not None:
|
|
406
|
-
if hasattr(col.default, "is_scalar") and col.default.is_scalar:
|
|
407
|
-
filtered_data[col.name] = getattr(col.default, "arg", None)
|
|
395
|
+
# Default values will be handled by __init__ method
|
|
408
396
|
|
|
409
397
|
init_data = {}
|
|
410
398
|
non_init_data = {}
|
|
@@ -427,6 +415,11 @@ class DataConversionMixin(DeferredLoadingMixin):
|
|
|
427
415
|
instance = cls(**init_data) # noqa
|
|
428
416
|
|
|
429
417
|
for field_name, value in non_init_data.items():
|
|
418
|
+
# Apply default value if value is None
|
|
419
|
+
if value is None:
|
|
420
|
+
default_value = instance._get_field_default_value(field_name) # noqa # type: ignore[reportAttributeAccessIssue]
|
|
421
|
+
if default_value is not None:
|
|
422
|
+
value = default_value
|
|
430
423
|
setattr(instance, field_name, value)
|
|
431
424
|
|
|
432
425
|
# Clear dirty fields since this is initial creation from dict
|
|
@@ -56,6 +56,9 @@ class ModelMixin(FieldCacheMixin, SignalMixin):
|
|
|
56
56
|
if hasattr(self, "_history_initialized"):
|
|
57
57
|
self._history_initialized = False
|
|
58
58
|
|
|
59
|
+
# Generate default values for fields not provided in kwargs
|
|
60
|
+
self._apply_default_values(kwargs)
|
|
61
|
+
|
|
59
62
|
# Set field values
|
|
60
63
|
for key, value in kwargs.items():
|
|
61
64
|
setattr(self, key, value)
|
|
@@ -500,6 +503,46 @@ class ModelMixin(FieldCacheMixin, SignalMixin):
|
|
|
500
503
|
relationships = getattr(self.__class__, "_relationships", {})
|
|
501
504
|
return set(relationships.keys())
|
|
502
505
|
|
|
506
|
+
def _apply_default_values(self, kwargs: dict):
|
|
507
|
+
"""Apply default values for fields not provided in kwargs.
|
|
508
|
+
|
|
509
|
+
Args:
|
|
510
|
+
kwargs: Dictionary of provided field values (will be modified)
|
|
511
|
+
"""
|
|
512
|
+
for field_name in self._get_field_names():
|
|
513
|
+
if field_name not in kwargs or kwargs[field_name] is None:
|
|
514
|
+
default_value = self._get_field_default_value(field_name)
|
|
515
|
+
if default_value is not None:
|
|
516
|
+
kwargs[field_name] = default_value
|
|
517
|
+
|
|
518
|
+
def _get_field_default_value(self, field_name: str):
|
|
519
|
+
"""Get default value for a field.
|
|
520
|
+
|
|
521
|
+
Args:
|
|
522
|
+
field_name: Name of the field
|
|
523
|
+
|
|
524
|
+
Returns:
|
|
525
|
+
Default value or None if no default
|
|
526
|
+
"""
|
|
527
|
+
field_attr = getattr(self.__class__, field_name, None)
|
|
528
|
+
if field_attr is None:
|
|
529
|
+
return None
|
|
530
|
+
|
|
531
|
+
# Priority: default_factory > SQLAlchemy default
|
|
532
|
+
if hasattr(field_attr, "get_default_factory"):
|
|
533
|
+
factory = field_attr.get_default_factory()
|
|
534
|
+
if factory and callable(factory):
|
|
535
|
+
return factory()
|
|
536
|
+
|
|
537
|
+
if hasattr(field_attr, "default") and field_attr.default is not None:
|
|
538
|
+
default_value = field_attr.default
|
|
539
|
+
if callable(default_value):
|
|
540
|
+
return default_value()
|
|
541
|
+
else:
|
|
542
|
+
return default_value
|
|
543
|
+
|
|
544
|
+
return None
|
|
545
|
+
|
|
503
546
|
|
|
504
547
|
class ObjectModel(ModelMixin, metaclass=ModelProcessor):
|
|
505
548
|
"""Base model class with configuration support and common functionality.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlobjects
|
|
3
|
-
Version: 1.0.
|
|
3
|
+
Version: 1.0.3
|
|
4
4
|
Summary: Django-style async ORM library based on SQLAlchemy with chainable queries, Q objects, and relationship loading
|
|
5
5
|
Author-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
6
6
|
Maintainer-email: XtraVisions <gitadmin@xtravisions.com>, Chen Hao <chenhao@xtravisions.com>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|