ecodev-core 0.0.45__tar.gz → 0.0.46__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.

Potentially problematic release.


This version of ecodev-core might be problematic. Click here for more details.

Files changed (32) hide show
  1. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/PKG-INFO +1 -1
  2. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/db_upsertion.py +15 -2
  3. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/version.py +6 -6
  4. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/pyproject.toml +1 -1
  5. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/LICENSE.md +0 -0
  6. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/README.md +0 -0
  7. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/__init__.py +0 -0
  8. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/app_activity.py +0 -0
  9. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/app_rights.py +0 -0
  10. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/app_user.py +0 -0
  11. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/auth_configuration.py +0 -0
  12. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/authentication.py +0 -0
  13. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/backup.py +0 -0
  14. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/check_dependencies.py +0 -0
  15. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/custom_equal.py +0 -0
  16. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/db_connection.py +0 -0
  17. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/db_filters.py +0 -0
  18. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/db_insertion.py +0 -0
  19. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/db_retrieval.py +0 -0
  20. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/deployment.py +0 -0
  21. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/email_sender.py +0 -0
  22. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/enum_utils.py +0 -0
  23. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/es_connection.py +0 -0
  24. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/list_utils.py +0 -0
  25. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/logger.py +0 -0
  26. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/pandas_utils.py +0 -0
  27. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/permissions.py +0 -0
  28. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/pydantic_utils.py +0 -0
  29. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/read_write.py +0 -0
  30. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/safe_utils.py +0 -0
  31. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/settings.py +0 -0
  32. {ecodev_core-0.0.45 → ecodev_core-0.0.46}/ecodev_core/sqlmodel_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ecodev-core
3
- Version: 0.0.45
3
+ Version: 0.0.46
4
4
  Summary: Low level sqlmodel/fastapi/pydantic building blocks
5
5
  License: MIT
6
6
  Author: Thomas Epelbaum
@@ -22,6 +22,7 @@ from ecodev_core.version import Version
22
22
  BATCH_SIZE = 5000
23
23
  FILTER_ON = 'filter_on'
24
24
  INFO = 'info'
25
+ SA_COLUMN_KWARGS = 'sa_column_kwargs'
25
26
 
26
27
 
27
28
  def sfield(**kwargs):
@@ -29,14 +30,26 @@ def sfield(**kwargs):
29
30
  Field constructor for columns not to be versioned. Those are the columns on which to select.
30
31
  They morally are a sort of unique identifier of a row (like id but more business meaningful)
31
32
  """
32
- return Field(**kwargs, sa_column_kwargs={INFO: {FILTER_ON: True}})
33
+ sa_column_kwargs = _get_sa_column_kwargs(kwargs, sfield=True)
34
+ return Field(**kwargs, sa_column_kwargs=sa_column_kwargs)
33
35
 
34
36
 
35
37
  def field(**kwargs):
36
38
  """
37
39
  Field constructor for columns to be versioned.
38
40
  """
39
- return Field(**kwargs, sa_column_kwargs={INFO: {FILTER_ON: False}})
41
+ sa_column_kwargs = _get_sa_column_kwargs(kwargs, sfield=False)
42
+ return Field(**kwargs, sa_column_kwargs=sa_column_kwargs)
43
+
44
+
45
+ def _get_sa_column_kwargs(kwargs, sfield: bool) -> dict:
46
+ """
47
+ Combine existing sa_column_kwargs with the new field necessary for versioning
48
+ """
49
+ if not (additional_vals := kwargs.get(SA_COLUMN_KWARGS)):
50
+ return {INFO: {FILTER_ON: sfield}}
51
+ kwargs.pop(SA_COLUMN_KWARGS)
52
+ return additional_vals | {INFO: {FILTER_ON: sfield}}
40
53
 
41
54
 
42
55
  def upsert_selector(values: SQLModel, db_schema: SQLModelMetaclass) -> SelectOfScalar:
@@ -38,7 +38,7 @@ class Version(SQLModel, table=True): # type: ignore
38
38
  Attributes are:
39
39
  - table: the table to version
40
40
  - column: the column of table to version
41
- - row_id: the the row id of the column of table to version
41
+ - row_id: the row id of the column of table to version
42
42
  - col_type: the column type
43
43
  - value: the value to store (previous row/column/table version)
44
44
  """
@@ -97,15 +97,15 @@ def _col_type_to_db(col_type: type | EnumType) -> ColType:
97
97
  """
98
98
  Forge ColType out of passed col_type
99
99
  """
100
- if col_type == int:
100
+ if issubclass(int, col_type):
101
101
  return ColType.INT
102
- if col_type == bool:
102
+ if issubclass(bool, col_type):
103
103
  return ColType.BOOL
104
- if col_type == float:
104
+ if issubclass(float, col_type):
105
105
  return ColType.FLOAT
106
- if col_type == str:
106
+ if issubclass(str, col_type):
107
107
  return ColType.STR
108
- if col_type == datetime:
108
+ if issubclass(datetime, col_type):
109
109
  return ColType.DATE
110
110
  return ColType.ENUM
111
111
 
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "ecodev-core"
3
- version = "0.0.45"
3
+ version = "0.0.46"
4
4
  description = "Low level sqlmodel/fastapi/pydantic building blocks"
5
5
  authors = ["Thomas Epelbaum <tomepel@gmail.com>",
6
6
  "Olivier Gabriel <olivier.gabriel.geom@gmail.com>",
File without changes
File without changes