sera-2 1.19.0__tar.gz → 1.19.1__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 (47) hide show
  1. {sera_2-1.19.0 → sera_2-1.19.1}/PKG-INFO +1 -1
  2. {sera_2-1.19.0 → sera_2-1.19.1}/pyproject.toml +1 -1
  3. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/make_python_model.py +9 -1
  4. {sera_2-1.19.0 → sera_2-1.19.1}/sera/misc/_utils.py +12 -0
  5. {sera_2-1.19.0 → sera_2-1.19.1}/sera/typing.py +1 -0
  6. {sera_2-1.19.0 → sera_2-1.19.1}/README.md +0 -0
  7. {sera_2-1.19.0 → sera_2-1.19.1}/sera/__init__.py +0 -0
  8. {sera_2-1.19.0 → sera_2-1.19.1}/sera/constants.py +0 -0
  9. {sera_2-1.19.0 → sera_2-1.19.1}/sera/exports/__init__.py +0 -0
  10. {sera_2-1.19.0 → sera_2-1.19.1}/sera/exports/schema.py +0 -0
  11. {sera_2-1.19.0 → sera_2-1.19.1}/sera/exports/test.py +0 -0
  12. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/__init__.py +0 -0
  13. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/api_helper.py +0 -0
  14. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/api_test_helper.py +0 -0
  15. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/base_orm.py +0 -0
  16. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/base_service.py +0 -0
  17. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/__init__.py +0 -0
  18. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_dcg.py +0 -0
  19. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_edge.py +0 -0
  20. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_flow.py +0 -0
  21. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_fn_signature.py +0 -0
  22. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_node.py +0 -0
  23. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_runtime.py +0 -0
  24. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/directed_computing_graph/_type_conversion.py +0 -0
  25. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/middlewares/__init__.py +0 -0
  26. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/middlewares/auth.py +0 -0
  27. {sera_2-1.19.0 → sera_2-1.19.1}/sera/libs/middlewares/uscp.py +0 -0
  28. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/__init__.py +0 -0
  29. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/__main__.py +0 -0
  30. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/make_app.py +0 -0
  31. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/make_python_api.py +0 -0
  32. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/make_python_services.py +0 -0
  33. {sera_2-1.19.0 → sera_2-1.19.1}/sera/make/make_typescript_model.py +0 -0
  34. {sera_2-1.19.0 → sera_2-1.19.1}/sera/misc/__init__.py +0 -0
  35. {sera_2-1.19.0 → sera_2-1.19.1}/sera/misc/_formatter.py +0 -0
  36. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/__init__.py +0 -0
  37. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_class.py +0 -0
  38. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_collection.py +0 -0
  39. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_constraints.py +0 -0
  40. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_datatype.py +0 -0
  41. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_default.py +0 -0
  42. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_enum.py +0 -0
  43. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_module.py +0 -0
  44. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_multi_lingual_string.py +0 -0
  45. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_parse.py +0 -0
  46. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_property.py +0 -0
  47. {sera_2-1.19.0 → sera_2-1.19.1}/sera/models/_schema.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: sera-2
3
- Version: 1.19.0
3
+ Version: 1.19.1
4
4
  Summary:
5
5
  Author: Binh Vu
6
6
  Author-email: bvu687@gmail.com
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "sera-2"
3
- version = "1.19.0"
3
+ version = "1.19.1"
4
4
  description = ""
5
5
  authors = ["Binh Vu <bvu687@gmail.com>"]
6
6
  readme = "README.md"
@@ -720,6 +720,12 @@ def make_python_data_model(
720
720
 
721
721
  program.import_("__future__.annotations", True)
722
722
  program.import_("msgspec", False)
723
+
724
+ ident_manager = ImportHelper(
725
+ program,
726
+ GLOBAL_IDENTS,
727
+ )
728
+
723
729
  if cls.db is not None:
724
730
  # if the class is stored in the database, we need to import the database module
725
731
  program.import_(
@@ -824,7 +830,9 @@ def make_python_data_model(
824
830
  lambda ast: ast.func(
825
831
  "as_composite",
826
832
  vars=as_composite_args,
827
- return_type=expr.ExprIdent(f"Optional[{cls.name}]"),
833
+ return_type=PredefinedFn.item_getter(
834
+ ident_manager.use("Optional"), expr.ExprIdent(cls.name)
835
+ ),
828
836
  comment="Create an embedded instance from the embedded columns in the database table. If all properties of this embedded class are None (indicating that the parent field is None), then this function will return None.",
829
837
  )(
830
838
  lambda ast_l1: ast_l1.if_(
@@ -191,6 +191,18 @@ def load_data(
191
191
 
192
192
  # Reset the sequence for each table
193
193
  for tbl in tbls:
194
+ # Check if the table has an auto-incrementing primary key
195
+ if not hasattr(tbl, "__table__") or not tbl.__table__.primary_key:
196
+ continue
197
+
198
+ pk_columns = tbl.__table__.primary_key.columns
199
+ has_foreign_key = any(len(col.foreign_keys) > 0 for col in pk_columns)
200
+ has_auto_increment = any(
201
+ col.autoincrement and col.type.python_type in (int,)
202
+ for col in pk_columns
203
+ )
204
+ if has_foreign_key or not has_auto_increment:
205
+ continue
194
206
  session.execute(
195
207
  text(
196
208
  f"SELECT setval('{tbl.__tablename__}_id_seq', (SELECT MAX(id) FROM \"{tbl.__tablename__}\"));"
@@ -38,4 +38,5 @@ GLOBAL_IDENTS = {
38
38
  "ASGIConnection": "litestar.connection.ASGIConnection",
39
39
  "UNSET": "sera.typing.UNSET",
40
40
  "ForeignKey": "sqlalchemy.ForeignKey",
41
+ "Optional": "typing.Optional",
41
42
  }
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