velocity-python 0.0.94__py3-none-any.whl → 0.0.95__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.
Potentially problematic release.
This version of velocity-python might be problematic. Click here for more details.
- velocity/__init__.py +1 -1
- velocity/db/servers/postgres/__init__.py +1 -0
- velocity/db/servers/postgres/sql.py +5 -5
- velocity/db/servers/tablehelper.py +5 -3
- {velocity_python-0.0.94.dist-info → velocity_python-0.0.95.dist-info}/METADATA +1 -1
- {velocity_python-0.0.94.dist-info → velocity_python-0.0.95.dist-info}/RECORD +9 -9
- {velocity_python-0.0.94.dist-info → velocity_python-0.0.95.dist-info}/WHEEL +0 -0
- {velocity_python-0.0.94.dist-info → velocity_python-0.0.95.dist-info}/licenses/LICENSE +0 -0
- {velocity_python-0.0.94.dist-info → velocity_python-0.0.95.dist-info}/top_level.txt +0 -0
velocity/__init__.py
CHANGED
|
@@ -256,7 +256,7 @@ class SQL:
|
|
|
256
256
|
|
|
257
257
|
# FROM clause
|
|
258
258
|
if th.foreign_keys:
|
|
259
|
-
sql_parts["FROM"].append(f"{
|
|
259
|
+
sql_parts["FROM"].append(f"{TableHelper.quote(table)} AS {TableHelper.quote(alias)}")
|
|
260
260
|
# Handle joins
|
|
261
261
|
done = []
|
|
262
262
|
for key, ref_info in th.foreign_keys.items():
|
|
@@ -270,11 +270,11 @@ class SQL:
|
|
|
270
270
|
):
|
|
271
271
|
raise ValueError(f"Invalid table alias info for {ref_table}.")
|
|
272
272
|
sql_parts["FROM"].append(
|
|
273
|
-
f"LEFT JOIN {
|
|
274
|
-
f"ON {
|
|
273
|
+
f"LEFT JOIN {TableHelper.quote(ref_table)} AS {TableHelper.quote(ref_info['alias'])} "
|
|
274
|
+
f"ON {TableHelper.quote(alias)}.{TableHelper.quote(ref_info['local_column'])} = {TableHelper.quote(ref_info['alias'])}.{TableHelper.quote(ref_info['ref_column'])}"
|
|
275
275
|
)
|
|
276
276
|
else:
|
|
277
|
-
sql_parts["FROM"].append(
|
|
277
|
+
sql_parts["FROM"].append(TableHelper.quote(table))
|
|
278
278
|
|
|
279
279
|
# WHERE
|
|
280
280
|
if where:
|
|
@@ -446,7 +446,7 @@ class SQL:
|
|
|
446
446
|
else:
|
|
447
447
|
sql_parts = []
|
|
448
448
|
sql_parts.append("UPDATE")
|
|
449
|
-
sql_parts.append(
|
|
449
|
+
sql_parts.append(TableHelper.quote(table))
|
|
450
450
|
sql_parts.append("SET " + ", ".join(set_clauses))
|
|
451
451
|
if where_clauses:
|
|
452
452
|
sql_parts.append("WHERE " + " AND ".join(where_clauses))
|
|
@@ -534,8 +534,10 @@ class TableHelper:
|
|
|
534
534
|
|
|
535
535
|
return " ".join(sql_parts), tuple(vals)
|
|
536
536
|
|
|
537
|
-
|
|
537
|
+
@classmethod
|
|
538
|
+
def quote(cls, data: Union[str, List[str]]) -> Union[str, List[str]]:
|
|
538
539
|
"""
|
|
540
|
+
Class method version of quote for backward compatibility.
|
|
539
541
|
Quotes identifiers (columns/tables) if needed, especially if they match reserved words or contain special chars.
|
|
540
542
|
|
|
541
543
|
Args:
|
|
@@ -545,7 +547,7 @@ class TableHelper:
|
|
|
545
547
|
Quoted identifier(s)
|
|
546
548
|
"""
|
|
547
549
|
if isinstance(data, list):
|
|
548
|
-
return [
|
|
550
|
+
return [cls.quote(item) for item in data]
|
|
549
551
|
|
|
550
552
|
if not isinstance(data, str):
|
|
551
553
|
raise ValueError(f"Data must be string or list, got {type(data)}")
|
|
@@ -565,7 +567,7 @@ class TableHelper:
|
|
|
565
567
|
if part.startswith('"') and part.endswith('"'):
|
|
566
568
|
quoted_parts.append(part)
|
|
567
569
|
# Quote if reserved word, contains special chars, or starts with digit
|
|
568
|
-
elif (part.upper() in
|
|
570
|
+
elif (part.upper() in cls.reserved or
|
|
569
571
|
re.search(r'[/\-\s]', part) or
|
|
570
572
|
(part and part[0].isdigit())):
|
|
571
573
|
# Escape any existing quotes in the identifier
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
velocity/__init__.py,sha256=
|
|
1
|
+
velocity/__init__.py,sha256=Ia6_qjrZBVx6x83-y9sI4W7UBXzNOKPSIofuJb7lVrk,106
|
|
2
2
|
velocity/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
velocity/app/invoices.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
velocity/app/orders.py,sha256=W-HAXEwY8-IFXbKh82HnMeRVZM7P-TWGEQOWtkLIzI4,6298
|
|
@@ -30,11 +30,11 @@ velocity/db/servers/sqlite.py,sha256=X210a5pENT9PiVK7f16fxXzFwEsq8fSe58Vouv2xqlk
|
|
|
30
30
|
velocity/db/servers/sqlite_reserved.py,sha256=-xmjl-Hgu6lKqkCAXq_6U8_aJX6gvaMgLMLdCt-Ej7o,3006
|
|
31
31
|
velocity/db/servers/sqlserver.py,sha256=0uGLEWRXiUhrOVTpEA1zvaKq1mcfiaCDp9r7gX-N71g,29914
|
|
32
32
|
velocity/db/servers/sqlserver_reserved.py,sha256=3LGQYU0qfvk6AbKety96gbzzfLbZ0dNHDPLxKGvvi4Q,4596
|
|
33
|
-
velocity/db/servers/tablehelper.py,sha256=
|
|
34
|
-
velocity/db/servers/postgres/__init__.py,sha256=
|
|
33
|
+
velocity/db/servers/tablehelper.py,sha256=S_759UBIqj-xn6IzwIu6wU7QSrUdLtg0-T80j23m23Y,22016
|
|
34
|
+
velocity/db/servers/postgres/__init__.py,sha256=FUvXO3R5CtKCTGRim1geisIxXbiG_aQ_VFSQX9HGsjw,529
|
|
35
35
|
velocity/db/servers/postgres/operators.py,sha256=A2T1qFwhzPl0fdXVhLZJhh5Qfx-qF8oZsDnxnq2n_V8,389
|
|
36
36
|
velocity/db/servers/postgres/reserved.py,sha256=5tKLaqFV-HrWRj-nsrxl5KGbmeM3ukn_bPZK36XEu8M,3648
|
|
37
|
-
velocity/db/servers/postgres/sql.py,sha256=
|
|
37
|
+
velocity/db/servers/postgres/sql.py,sha256=dDUcdErrAgWulrr6582p4Zf1co6-PH8MfVU2q9KRisI,41416
|
|
38
38
|
velocity/db/servers/postgres/types.py,sha256=Wa45ppVf_pdWul-jYWFRGMl6IdSq8dAp10SKnhL7osQ,3757
|
|
39
39
|
velocity/misc/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
40
|
velocity/misc/db.py,sha256=MPgt-kkukKR_Wh_S_5W-MyDgaeoZ4YLoDJ54wU2ppm4,2830
|
|
@@ -47,8 +47,8 @@ velocity/misc/tools.py,sha256=_bGneHHA_BV-kUonzw5H3hdJ5AOJRCKfzhgpkFbGqIo,1502
|
|
|
47
47
|
velocity/misc/conv/__init__.py,sha256=MLYF58QHjzfDSxb1rdnmLnuEQCa3gnhzzZ30CwZVvQo,40
|
|
48
48
|
velocity/misc/conv/iconv.py,sha256=d4_BucW8HTIkGNurJ7GWrtuptqUf-9t79ObzjJ5N76U,10603
|
|
49
49
|
velocity/misc/conv/oconv.py,sha256=h5Lo05DqOQnxoD3y6Px_MQP_V-pBbWf8Hkgkb9Xp1jk,6032
|
|
50
|
-
velocity_python-0.0.
|
|
51
|
-
velocity_python-0.0.
|
|
52
|
-
velocity_python-0.0.
|
|
53
|
-
velocity_python-0.0.
|
|
54
|
-
velocity_python-0.0.
|
|
50
|
+
velocity_python-0.0.95.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
51
|
+
velocity_python-0.0.95.dist-info/METADATA,sha256=0ve_k4tFITuVudvOEsARj3hIPyuaAhTCEWXhTiTUA3g,33022
|
|
52
|
+
velocity_python-0.0.95.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
53
|
+
velocity_python-0.0.95.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
54
|
+
velocity_python-0.0.95.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|