ic-python-db 0.7.3__tar.gz → 0.7.5__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.
Files changed (24) hide show
  1. {ic_python_db-0.7.3/ic_python_db.egg-info → ic_python_db-0.7.5}/PKG-INFO +1 -1
  2. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/__init__.py +1 -1
  3. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/entity.py +11 -6
  4. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/properties.py +4 -0
  5. {ic_python_db-0.7.3 → ic_python_db-0.7.5/ic_python_db.egg-info}/PKG-INFO +1 -1
  6. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/pyproject.toml +1 -1
  7. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/setup.py +1 -1
  8. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/LICENSE +0 -0
  9. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/MANIFEST.in +0 -0
  10. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/README.md +0 -0
  11. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/_cdk.py +0 -0
  12. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/constants.py +0 -0
  13. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/context.py +0 -0
  14. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/db_engine.py +0 -0
  15. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/hooks.py +0 -0
  16. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/mixins.py +0 -0
  17. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/py.typed +0 -0
  18. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/storage.py +0 -0
  19. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db/system_time.py +0 -0
  20. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db.egg-info/SOURCES.txt +0 -0
  21. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db.egg-info/dependency_links.txt +0 -0
  22. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/ic_python_db.egg-info/top_level.txt +0 -0
  23. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/requirements-dev.txt +0 -0
  24. {ic_python_db-0.7.3 → ic_python_db-0.7.5}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ic_python_db
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: A lightweight key-value database written in Python, intended for use on the Internet Computer (IC)
5
5
  Home-page: https://github.com/smart-social-contracts/ic-python-db
6
6
  Author: Smart Social Contracts
@@ -19,7 +19,7 @@ from .properties import (
19
19
  from .storage import MemoryStorage, Storage
20
20
  from .system_time import SystemTime
21
21
 
22
- __version__ = "0.7.3"
22
+ __version__ = "0.7.5"
23
23
  __all__ = [
24
24
  "Database",
25
25
  "Entity",
@@ -180,7 +180,8 @@ class Entity:
180
180
  setattr(self, k, v)
181
181
  self._do_not_save = False
182
182
 
183
- self._save()
183
+ if not self._loaded:
184
+ self._save()
184
185
 
185
186
  @classmethod
186
187
  def new(cls, **kwargs):
@@ -386,10 +387,16 @@ class Entity:
386
387
  # Create instance first
387
388
  entity = cls(**data, _loaded=True)
388
389
 
389
- # Extract relations
390
- relations = {}
390
+ # If migration was applied, persist the migrated data
391
+ if stored_version != current_version:
392
+ entity._save()
393
+
394
+ # Restore legacy "relations" block if present in serialized data.
395
+ # Otherwise keep the _relations that __init__ already populated
396
+ # via relationship descriptors (OneToMany, ManyToOne, etc.).
391
397
  if "relations" in data:
392
398
  relations_data = data.pop("relations")
399
+ relations = {}
393
400
  for rel_name, rel_refs in relations_data.items():
394
401
  relations[rel_name] = []
395
402
  for ref in rel_refs:
@@ -400,9 +407,7 @@ class Entity:
400
407
  )
401
408
  if related:
402
409
  relations[rel_name].append(related)
403
-
404
- # Set relations after loading
405
- entity._relations = relations
410
+ entity._relations = relations
406
411
 
407
412
  return entity
408
413
 
@@ -450,6 +450,8 @@ class OneToOne(Relation[E]):
450
450
 
451
451
  # Get current value if any
452
452
  current = self.__get__(obj)
453
+ if current is value:
454
+ return
453
455
  if current is not None:
454
456
  # Remove existing relation
455
457
  obj.remove_relation(self.name, self.reverse_name, current)
@@ -458,6 +460,8 @@ class OneToOne(Relation[E]):
458
460
  existing = value.get_relations(self.reverse_name)
459
461
  if existing:
460
462
  existing_entity = existing[0]
463
+ if existing_entity is obj:
464
+ return
461
465
  # Remove the existing relation from both sides
462
466
  existing_entity.remove_relation(self.name, self.reverse_name, value)
463
467
  value.remove_relation(self.reverse_name, self.name, existing_entity)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ic_python_db
3
- Version: 0.7.3
3
+ Version: 0.7.5
4
4
  Summary: A lightweight key-value database written in Python, intended for use on the Internet Computer (IC)
5
5
  Home-page: https://github.com/smart-social-contracts/ic-python-db
6
6
  Author: Smart Social Contracts
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "ic_python_db"
7
- version = "0.7.3"
7
+ version = "0.7.5"
8
8
  description = "A lightweight key-value database written in Python, intended for use on the Internet Computer (IC)"
9
9
  readme = "README.md"
10
10
  authors = [
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
5
5
 
6
6
  setup(
7
7
  name="ic_python_db",
8
- version="0.7.3",
8
+ version="0.7.5",
9
9
  author="Smart Social Contracts",
10
10
  author_email="smartsocialcontracts@gmail.com",
11
11
  description="A lightweight key-value database with entity relationships and audit logging",
File without changes
File without changes
File without changes
File without changes