velocity-python 0.0.64__py3-none-any.whl → 0.0.66__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = version = "0.0.64"
1
+ __version__ = version = "0.0.66"
2
2
 
3
3
  from . import aws
4
4
  from . import db
@@ -57,6 +57,8 @@ class Engine:
57
57
  May also be used to decorate a class, in which case all methods are wrapped in a transaction if they accept `tx`.
58
58
  With no arguments, returns a new Transaction directly.
59
59
  """
60
+ # print("Transaction", func_or_cls.__name__, type(func_or_cls))
61
+
60
62
  if func_or_cls is None:
61
63
  return Transaction(self)
62
64
 
@@ -64,15 +66,21 @@ class Engine:
64
66
  return classmethod(self.transaction(func_or_cls.__func__))
65
67
 
66
68
  if inspect.isfunction(func_or_cls) or inspect.ismethod(func_or_cls):
69
+ names = list(inspect.signature(func_or_cls).parameters.keys())
70
+ # print(func_or_cls.__name__, names)
71
+ if "_tx" in names:
72
+ raise NameError(
73
+ f"In function {func_or_cls.__name__}, '_tx' is not allowed as a parameter."
74
+ )
67
75
 
68
76
  @wraps(func_or_cls)
69
77
  def new_function(*args, **kwds):
70
78
  tx = None
71
79
  names = list(inspect.signature(func_or_cls).parameters.keys())
72
- if "_tx" in names:
73
- raise NameError(
74
- f"In function {func_or_cls.__name__}, '_tx' is not allowed as a parameter."
75
- )
80
+
81
+ # print("inside", func_or_cls.__name__)
82
+ # print(names)
83
+ # print(args, kwds)
76
84
 
77
85
  if "tx" not in names:
78
86
  # The function doesn't even declare a `tx` parameter, so run normally.
@@ -91,33 +99,31 @@ class Engine:
91
99
  if len(args) > pos:
92
100
  if isinstance(args[pos], Transaction):
93
101
  tx = args[pos]
94
- else:
95
- raise TypeError(
96
- f"In function {func_or_cls.__name__}, positional argument `tx` must be a Transaction object."
97
- )
102
+
98
103
  if tx:
99
104
  return self.exec_function(func_or_cls, tx, *args, **kwds)
105
+
100
106
  with Transaction(self) as local_tx:
101
107
  pos = names.index("tx")
102
- args = list(args)
103
- args.insert(pos, local_tx)
104
- args = tuple(args)
105
- return self.exec_function(func_or_cls, local_tx, *args, **kwds)
108
+ new_args = args[:pos] + (local_tx,) + args[pos:]
109
+ return self.exec_function(func_or_cls, local_tx, *new_args, **kwds)
106
110
 
107
111
  return new_function
108
112
 
109
113
  if inspect.isclass(func_or_cls):
110
114
 
111
- class NewCls(func_or_cls):
112
- pass
115
+ NewCls = type(func_or_cls.__name__, (func_or_cls,), {})
116
+
117
+ for attr_name in dir(func_or_cls):
118
+ # Optionally skip special methods
119
+ if attr_name.startswith("__") and attr_name.endswith("__"):
120
+ continue
121
+
122
+ attr = getattr(func_or_cls, attr_name)
123
+
124
+ if callable(attr):
125
+ setattr(NewCls, attr_name, self.transaction(attr))
113
126
 
114
- for attr_name, attr_value in func_or_cls.__dict__.items():
115
- if (
116
- isinstance(attr_value, classmethod)
117
- or inspect.isfunction(attr_value)
118
- or inspect.ismethod(attr_value)
119
- ):
120
- setattr(NewCls, attr_name, self.transaction(attr_value))
121
127
  return NewCls
122
128
 
123
129
  return Transaction(self)
@@ -144,6 +144,11 @@ class TableHelper:
144
144
  Extracts the 'bare' column name from an expression, ignoring function calls, operators, etc.
145
145
  """
146
146
  expr = sql_expression.replace('"', "")
147
+
148
+ # Remove any alias part (e.g., "as num_donors").
149
+ # This regex removes any trailing alias defined using "as".
150
+ expr = re.sub(r"(?i)\s+as\s+\w+$", "", expr).strip()
151
+
147
152
  expr = self.remove_operator(expr)
148
153
  if not self.are_parentheses_balanced(expr):
149
154
  raise ValueError(f"Unbalanced parentheses in expression: {expr}")
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: velocity-python
3
- Version: 0.0.64
3
+ Version: 0.0.66
4
4
  Summary: A rapid application development library for interfacing with data storage
5
5
  Author-email: Paul Perez <pperez@codeclubs.org>
6
6
  Project-URL: Homepage, https://codeclubs.org/projects/velocity
@@ -20,6 +20,7 @@ Provides-Extra: sqlserver
20
20
  Requires-Dist: python-tds; extra == "sqlserver"
21
21
  Provides-Extra: postgres
22
22
  Requires-Dist: psycopg2-binary; extra == "postgres"
23
+ Dynamic: license-file
23
24
 
24
25
  # Velocity.DB
25
26
 
@@ -1,4 +1,4 @@
1
- velocity/__init__.py,sha256=BV64vuHaj6lbPZ96w6YkJ_mgqq506ohvETaJVjBy-_s,88
1
+ velocity/__init__.py,sha256=xyG5aYyKP5U2cxz1pPLUsDp9NpDJb92wzwYIorLV0Ro,88
2
2
  velocity/aws/__init__.py,sha256=GBTEr02whnCH3TG-BWCpUC3KfHY3uNxD21g0OvsVJnc,598
3
3
  velocity/aws/handlers/__init__.py,sha256=xnpFZJVlC2uoeeFW4zuPST8wA8ajaQDky5Y6iXZzi3A,172
4
4
  velocity/aws/handlers/context.py,sha256=UIjNR83y2NSIyK8HMPX8t5tpJHFNabiZvNgmmdQL3HA,1822
@@ -10,7 +10,7 @@ velocity/db/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
10
10
  velocity/db/core/column.py,sha256=tAr8tL3a2nyaYpNHhGl508FrY_pGZTzyYgjAV5CEBv4,4092
11
11
  velocity/db/core/database.py,sha256=3zNGItklu9tZCKsbx2T2vCcU1so8AL9PPL0DLjvaz6s,3554
12
12
  velocity/db/core/decorators.py,sha256=ZwwNc6wGx7Qe7xPZGgeHuqqtXEeNqyDXB0M5ROY-40I,4612
13
- velocity/db/core/engine.py,sha256=Ykw_G78UeS59JZLRHqOrprfOv-uxm7HshA6V0cST6QE,13074
13
+ velocity/db/core/engine.py,sha256=NVsS9HPu13Lzuz7UHjUdsCRuBe2cYVKwgAVf9SLc1E0,13123
14
14
  velocity/db/core/exceptions.py,sha256=MOWyA1mlMe8eWbFkEHK0Lp9czdplpRyqbAn2JfGmMrM,707
15
15
  velocity/db/core/result.py,sha256=OVqoMwlx3CHNNwr-JGWRx5I8u_YX6hlUpecx99UT5nE,6164
16
16
  velocity/db/core/row.py,sha256=aliLYTTFirgJsOvmUsANwJMyxaATuhpGpFJhcu_twwY,6709
@@ -24,7 +24,7 @@ velocity/db/servers/sqlite.py,sha256=X210a5pENT9PiVK7f16fxXzFwEsq8fSe58Vouv2xqlk
24
24
  velocity/db/servers/sqlite_reserved.py,sha256=-xmjl-Hgu6lKqkCAXq_6U8_aJX6gvaMgLMLdCt-Ej7o,3006
25
25
  velocity/db/servers/sqlserver.py,sha256=0uGLEWRXiUhrOVTpEA1zvaKq1mcfiaCDp9r7gX-N71g,29914
26
26
  velocity/db/servers/sqlserver_reserved.py,sha256=3LGQYU0qfvk6AbKety96gbzzfLbZ0dNHDPLxKGvvi4Q,4596
27
- velocity/db/servers/tablehelper.py,sha256=0QsQc73q2En3p0778DKAEiEo3ZtZowgFpAKZXwORjfw,9816
27
+ velocity/db/servers/tablehelper.py,sha256=8oAbscs3TqCk-kc-RYzWRotYVmh0OG4l1E6RzQVNGU0,10004
28
28
  velocity/db/servers/postgres/__init__.py,sha256=n6Ti5USqXME8Df18iklC-D0eI1Hr0szZAeSS3xz5ycQ,464
29
29
  velocity/db/servers/postgres/operators.py,sha256=A2T1qFwhzPl0fdXVhLZJhh5Qfx-qF8oZsDnxnq2n_V8,389
30
30
  velocity/db/servers/postgres/reserved.py,sha256=5tKLaqFV-HrWRj-nsrxl5KGbmeM3ukn_bPZK36XEu8M,3648
@@ -40,8 +40,8 @@ velocity/misc/timer.py,sha256=cN3aS0t6HLlhYfF2Ir6ihJehxNrWf9ebaLzXUaWRKEA,1637
40
40
  velocity/misc/conv/__init__.py,sha256=MLYF58QHjzfDSxb1rdnmLnuEQCa3gnhzzZ30CwZVvQo,40
41
41
  velocity/misc/conv/iconv.py,sha256=d4_BucW8HTIkGNurJ7GWrtuptqUf-9t79ObzjJ5N76U,10603
42
42
  velocity/misc/conv/oconv.py,sha256=h5Lo05DqOQnxoD3y6Px_MQP_V-pBbWf8Hkgkb9Xp1jk,6032
43
- velocity_python-0.0.64.dist-info/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
44
- velocity_python-0.0.64.dist-info/METADATA,sha256=vAWChPbSU4kqhj3uwJP8mdpgT2SvwyHY84Dv_l8FQ6E,8519
45
- velocity_python-0.0.64.dist-info/WHEEL,sha256=beeZ86-EfXScwlR_HKu4SllMC9wUEj_8Z_4FJ3egI2w,91
46
- velocity_python-0.0.64.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
47
- velocity_python-0.0.64.dist-info/RECORD,,
43
+ velocity_python-0.0.66.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
44
+ velocity_python-0.0.66.dist-info/METADATA,sha256=JIZQIeJNIqNiJDj4WtkAhNGTIJzrg_9XrMYZ2FbuHFo,8541
45
+ velocity_python-0.0.66.dist-info/WHEEL,sha256=1tXe9gY0PYatrMPMDd6jXqjfpz_B-Wqm32CPfRC58XU,91
46
+ velocity_python-0.0.66.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
47
+ velocity_python-0.0.66.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (76.1.0)
2
+ Generator: setuptools (77.0.3)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5