sera-2 1.19.0__py3-none-any.whl → 1.19.1__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.
sera/make/make_python_model.py
CHANGED
@@ -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=
|
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_(
|
sera/misc/_utils.py
CHANGED
@@ -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__}\"));"
|
sera/typing.py
CHANGED
@@ -23,12 +23,12 @@ sera/make/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
23
23
|
sera/make/__main__.py,sha256=HRfOR53p351h6KblVvYm3DLhDIfEtk6R0kjl78_S_S8,1453
|
24
24
|
sera/make/make_app.py,sha256=n9NtW73O3s_5Q31VHIRmnd-jEIcpDO7ksAsOdovde2s,5999
|
25
25
|
sera/make/make_python_api.py,sha256=iXGbKQ3IJvsY1ur_fhurr_THFNnH66E3Wl85o0emUbw,26853
|
26
|
-
sera/make/make_python_model.py,sha256=
|
26
|
+
sera/make/make_python_model.py,sha256=RfUATMs6d_glxbKnpLum9tsU2pNOyifvJX76S8pI_DY,62964
|
27
27
|
sera/make/make_python_services.py,sha256=0ZpWLwQ7Nwfn8BXAikAB4JRpNknpSJyJgY5b1cjtxV4,2073
|
28
28
|
sera/make/make_typescript_model.py,sha256=1ouYFCeqOlwEzsGBiXUn4VZtLJjJW7GSacdOSlQzhjI,67012
|
29
29
|
sera/misc/__init__.py,sha256=rOmGMv7QNzpSKZSyxChbRmEnBr3O443UlLGS0FIs3AI,561
|
30
30
|
sera/misc/_formatter.py,sha256=aCGYL08l8f3aLODHxSocxBBwkRYEo3K1QzCDEn3suj0,1685
|
31
|
-
sera/misc/_utils.py,sha256=
|
31
|
+
sera/misc/_utils.py,sha256=_-17XbK6qp3HobcI9iLF4xfaATvFg1ckUzgg7r7Ctmw,7135
|
32
32
|
sera/models/__init__.py,sha256=vJC5Kzo_N7wd16ocNPy1VvAZDGNiWeiAhWJ4ihATKvA,780
|
33
33
|
sera/models/_class.py,sha256=1J4Bd_LanzhhDWwZFHWGtFYD7lupe_alaB3D02ebNDI,2862
|
34
34
|
sera/models/_collection.py,sha256=ZnQEriKC4X88Zz48Kn1AVZKH-1_l8OgWa-zf2kcQOOE,1414
|
@@ -41,7 +41,7 @@ sera/models/_multi_lingual_string.py,sha256=JETN6k00VH4wrA4w5vAHMEJV8fp3SY9bJebs
|
|
41
41
|
sera/models/_parse.py,sha256=ciTLzCkO0q6xA1R_rHbnYJYK3Duo2oh56WeuwxXwJaI,12392
|
42
42
|
sera/models/_property.py,sha256=9yMDxrmbyuF6-29lQjiq163Xzwbk75TlmGBpu0NLpkI,7485
|
43
43
|
sera/models/_schema.py,sha256=VxJEiqgVvbXgcSUK4UW6JnRcggk4nsooVSE6MyXmfNY,1636
|
44
|
-
sera/typing.py,sha256=
|
45
|
-
sera_2-1.19.
|
46
|
-
sera_2-1.19.
|
47
|
-
sera_2-1.19.
|
44
|
+
sera/typing.py,sha256=m4rir-fB6Cgcm7_ZSXXcNdla2LJgq96WXxtTTrDaJno,1058
|
45
|
+
sera_2-1.19.1.dist-info/METADATA,sha256=vhXuNeYXDuvLW_dW_7jStIcyq0OhEqV9XXp74taTQzY,936
|
46
|
+
sera_2-1.19.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
|
47
|
+
sera_2-1.19.1.dist-info/RECORD,,
|
File without changes
|