sera-2 1.26.2__py3-none-any.whl → 1.26.4__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.
@@ -96,29 +96,47 @@ def make_query(schema: Schema, cls: Class, pkg: Package):
96
96
  for dep in tstype.deps:
97
97
  program.import_(dep, is_import_attr=True)
98
98
 
99
+ query_ops = []
100
+
99
101
  if tstype.type == "string":
100
- op = '"fuzzy"'
101
- elif tstype.type in "number" or tstype.type == "Date":
102
- op = '"eq" | "ne" | "lt" | "lte" | "gt" | "gte"'
102
+ query_ops.append(('"fuzzy"', tstype.type))
103
+ elif tstype.type == "number":
104
+ if (
105
+ isinstance(prop, DataProperty)
106
+ and prop.db is not None
107
+ and prop.db.is_primary_key
108
+ ) or (isinstance(prop, ObjectProperty) and prop.target.db is not None):
109
+ # primary key or foreign key, we only support a limited set of operations
110
+ query_ops.append(('"eq" | "ne"', tstype.type))
111
+ else:
112
+ query_ops.append(
113
+ ('"eq" | "ne" | "lt" | "lte" | "gt" | "gte"', tstype.type)
114
+ )
115
+ query_ops.append(('"bti"', "[number, number]"))
103
116
  elif tstype.is_enum_type():
104
- op = '"eq" | "ne"'
117
+ query_ops.append(('"eq" | "ne"', tstype.type))
118
+ elif tstype.type == "Date":
119
+ # for date type, we use iso string as the value
120
+ query_ops.append(('"eq" | "ne" | "lt" | "lte" | "gt" | "gte"', "string"))
121
+ query_ops.append(('"bti"', "[string, string]"))
105
122
  else:
106
123
  raise NotImplementedError(tstype.type)
107
124
 
108
- if tstype.type == "Date":
109
- # for date type, we use timestamp (number) for comparison
110
- value = "number"
111
- else:
112
- value = tstype.type
113
-
114
125
  query_condition_args.append(
115
126
  (
116
127
  expr.ExprIdent(tspropname + "?"),
117
- PredefinedFn.dict(
118
- [
119
- (expr.ExprIdent("op"), expr.ExprIdent(op)),
120
- (expr.ExprIdent("value"), expr.ExprIdent(value)),
121
- ]
128
+ expr.ExprRawTypescript(
129
+ " | ".join(
130
+ [
131
+ PredefinedFn.dict(
132
+ [
133
+ (expr.ExprIdent("op"), expr.ExprIdent(op)),
134
+ (expr.ExprIdent("value"), expr.ExprIdent(value)),
135
+ ]
136
+ ).to_typescript()
137
+ for op, value in query_ops
138
+ ]
139
+ )
122
140
  ),
123
141
  )
124
142
  )
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: sera-2
3
- Version: 1.26.2
3
+ Version: 1.26.4
4
4
  Summary:
5
5
  Author: Binh Vu
6
6
  Author-email: bvu687@gmail.com
@@ -26,13 +26,14 @@ sera/make/make_app.py,sha256=dTzpJRPGoCojCdJr1TAzwbaquctwwitrGPxkRm9skpo,6033
26
26
  sera/make/make_python_api.py,sha256=sfaYnX6Vwj0xWPpvpWbBhq8GyNHgNkvwlyZr7NDCO0k,24770
27
27
  sera/make/make_python_model.py,sha256=cW3RGVttuZWLVWrEg-NppSknWoTKCRE2mar9yyhj-gU,72545
28
28
  sera/make/make_python_services.py,sha256=SvdU--QF23FN_d-Ao07CeXIK9d5eL_-mdXYwXx69dRE,2102
29
- sera/make/make_typescript_model.py,sha256=SOuTojrMD3QQe_jW7cGpYdNV5upZwDYHR8QDW-wLOKc,56365
29
+ sera/make/make_typescript_model.py,sha256=bhvYbQKST1DT0pnkNOpwcmsaeVnUcNfVvHxUq2LAoo4,17604
30
30
  sera/make/py_backend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
31
31
  sera/make/py_backend/misc.py,sha256=lZNkrniR2OZiyK4rei1Yl_mRYBR_QzOpqVO_gMWbJD4,487
32
32
  sera/make/ts_frontend/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
33
- sera/make/ts_frontend/make_class_schema.py,sha256=FHTNQOJl-Zz6CHRT6J2GOZxpIeyMDqMRNTK9XUiM578,14489
33
+ sera/make/ts_frontend/make_class_schema.py,sha256=JrUNBl5yJSbVFrdGcuC7sG0A-HhmXl24VJWCTVkDh8I,14458
34
+ sera/make/ts_frontend/make_draft_model.py,sha256=LY1HP6BuEmtxEevqAWMe-GJyTbK-yDIsUjLjZdd-0Rg,32570
34
35
  sera/make/ts_frontend/make_enums.py,sha256=3U6Dt5Y4DM6D_ZiitcVHXtNQyA9cTE046WCDQCDOvSU,2596
35
- sera/make/ts_frontend/make_query.py,sha256=mQUK5H7jN5sgd8GzhswshWdt6_wKSFv1HnxuHj6uAd4,4771
36
+ sera/make/ts_frontend/make_query.py,sha256=YnUBwMW_3LRJBoV2dpim6M6ouNhPPloCT2YBEBLgU7M,5731
36
37
  sera/make/ts_frontend/misc.py,sha256=A54nMg4dsn1AC_6T1tFRW3rZAJ71d7SHEMrFOdsI3jo,1011
37
38
  sera/misc/__init__.py,sha256=ee7OODdWPKP8pCDxsfg1EOdxxKFMJCoNMljgV0NCxBw,767
38
39
  sera/misc/_formatter.py,sha256=aCGYL08l8f3aLODHxSocxBBwkRYEo3K1QzCDEn3suj0,1685
@@ -50,6 +51,6 @@ sera/models/_parse.py,sha256=nihBEDni-jKwecSBagd6bupDOuCzGviuoD9u6-rT64Q,13203
50
51
  sera/models/_property.py,sha256=Qo23KZl5OQNbuceygicgC3_Yv5ve1KxiFiMoWq6Ljj0,7758
51
52
  sera/models/_schema.py,sha256=VxJEiqgVvbXgcSUK4UW6JnRcggk4nsooVSE6MyXmfNY,1636
52
53
  sera/typing.py,sha256=7S6Ah-Yfcl8a0xAJ4lxEcguq3rYVM7SBeOiuxyJhC04,1089
53
- sera_2-1.26.2.dist-info/METADATA,sha256=vOrf5maMTAY8NaLVi_mAZEmiWwNWnWkNbAPnsEPz4LE,987
54
- sera_2-1.26.2.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
55
- sera_2-1.26.2.dist-info/RECORD,,
54
+ sera_2-1.26.4.dist-info/METADATA,sha256=9tRFamnahw1dsWTpsIeoBGCkF8pLU2o6rNlQG2PExbA,987
55
+ sera_2-1.26.4.dist-info/WHEEL,sha256=zp0Cn7JsFoX2ATtOhtaFYIiE2rmFAD4OcMhtUki8W3U,88
56
+ sera_2-1.26.4.dist-info/RECORD,,
@@ -1,4 +1,4 @@
1
1
  Wheel-Version: 1.0
2
- Generator: poetry-core 2.2.0
2
+ Generator: poetry-core 2.2.1
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any