velocity-python 0.0.93__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 CHANGED
@@ -1,4 +1,4 @@
1
- __version__ = version = "0.0.93"
1
+ __version__ = version = "0.0.95"
2
2
 
3
3
  from . import aws
4
4
  from . import db
@@ -4,6 +4,7 @@ from .sql import SQL
4
4
  from velocity.db.core import engine
5
5
 
6
6
 
7
+
7
8
  def initialize(config=None, **kwargs):
8
9
  if not config:
9
10
  # Keep the default config inside this function.
@@ -256,7 +256,7 @@ class SQL:
256
256
 
257
257
  # FROM clause
258
258
  if th.foreign_keys:
259
- sql_parts["FROM"].append(f"{th.quote(table)} AS {th.quote(alias)}")
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 {th.quote(ref_table)} AS {th.quote(ref_info['alias'])} "
274
- f"ON {th.quote(alias)}.{th.quote(ref_info['local_column'])} = {th.quote(ref_info['alias'])}.{th.quote(ref_info['ref_column'])}"
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(th.quote(table))
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(th.quote(table))
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
- def quote(self, data: Union[str, List[str]]) -> Union[str, List[str]]:
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 [self.quote(item) for item in data]
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 self.reserved or
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